Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7c5d79a8
Commit
7c5d79a8
authored
Apr 08, 1998
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added timeout attribute
parent
4baa0f8d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
29 deletions
+53
-29
lib/python/Products/MailHost/MailHost.py
lib/python/Products/MailHost/MailHost.py
+30
-18
lib/python/Products/MailHost/addMailHost_form.dtml
lib/python/Products/MailHost/addMailHost_form.dtml
+11
-6
lib/python/Products/MailHost/manageMailHost.dtml
lib/python/Products/MailHost/manageMailHost.dtml
+12
-5
No files found.
lib/python/Products/MailHost/MailHost.py
View file @
7c5d79a8
...
...
@@ -9,19 +9,20 @@ import Globals
from
Scheduler.OneTimeEvent
import
OneTimeEvent
from
ImageFile
import
ImageFile
#$Id: MailHost.py,v 1.2
5 1998/01/13 23:06:10 brian
Exp $
__version__
=
"$Revision: 1.2
5
$"
[
11
:
-
2
]
#$Id: MailHost.py,v 1.2
6 1998/04/08 15:34:52 jeffrey
Exp $
__version__
=
"$Revision: 1.2
6
$"
[
11
:
-
2
]
smtpError
=
"SMTP Error"
MailHostError
=
"MailHost Error"
addForm
=
HTMLFile
(
'addMailHost_form'
,
globals
(),
localhost
=
gethostname
())
def
add
(
self
,
id
,
title
=
''
,
smtp_host
=
None
,
localhost
=
'localhost'
,
smtp_port
=
25
,
REQUEST
=
None
):
localhost
=
'localhost'
,
smtp_port
=
25
,
timeout
=
1.0
,
REQUEST
=
None
):
' add a MailHost into the system '
i
=
MailHost
()
#create new mail host
i
.
id
=
id
#give it id
i
.
title
=
title
#title
i
.
_init
(
localHost
=
localhost
,
smtpHost
=
smtp_host
,
smtpPort
=
smtp_port
)
i
.
_init
(
localHost
=
localhost
,
smtpHost
=
smtp_host
,
smtpPort
=
smtp_port
,
timeout
=
timeout
)
self
.
_setObject
(
id
,
i
)
#register it
if
REQUEST
:
return
self
.
manage_main
(
self
,
REQUEST
)
...
...
@@ -33,6 +34,8 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
index_html
=
None
icon
=
'misc_/MailHost/MHIcon'
timeout
=
1.0
manage_options
=
({
'icon'
:
''
,
'label'
:
'Edit'
,
'action'
:
'manage_main'
,
'target'
:
'manage_main'
,
},
...
...
@@ -54,19 +57,20 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
'nothing yet'
pass
def
_init
(
self
,
localHost
,
smtpHost
,
smtpPort
):
def
_init
(
self
,
localHost
,
smtpHost
,
smtpPort
,
timeout
=
1
):
self
.
localHost
=
localHost
self
.
smtpHost
=
smtpHost
self
.
smtpPort
=
smtpPort
self
.
sentMessages
=
0
self
.
timeout
=
timeout
def
manage_makeChanges
(
self
,
title
,
localHost
,
smtpHost
,
smtpPort
,
REQUEST
=
None
):
timeout
,
REQUEST
=
None
):
'make the changes'
self
.
title
=
title
self
.
localHost
=
localHost
self
.
smtpHost
=
smtpHost
self
.
smtpPort
=
smtpPort
self
.
timeout
=
timeout
if
REQUEST
:
return
MessageDialog
(
title
=
'Changed %s'
%
self
.
__name__
,
message
=
'%s has been updated'
%
self
.
id
,
...
...
@@ -90,7 +94,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
Globals
.
Scheduler
.
schedule
(
OneTimeEvent
(
Send
,
(
trueself
.
smtpHost
,
trueself
.
smtpPort
,
trueself
.
localHost
,
trueself
.
localHost
,
trueself
.
timeout
,
headers
[
'from'
],
headers
[
'to'
],
headers
[
'subject'
],
messageText
),
...
...
@@ -115,9 +119,10 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
raise
MailHostError
,
"Message missing SMTP Header '%s'"
\
%
requiredHeader
SendMail
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
).
send
(
mfrom
=
headers
[
'from'
],
mto
=
headers
[
'to'
],
subj
=
headers
[
'subject'
],
body
=
messageText
)
SendMail
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
,
self
.
timeout
).
send
(
mfrom
=
headers
[
'from'
],
mto
=
headers
[
'to'
],
subj
=
headers
[
'subject'
],
body
=
messageText
)
def
scheduledSend
(
self
,
messageText
,
mto
=
None
,
mfrom
=
None
,
subject
=
None
):
if
subject
:
messageText
=
"subject: %s
\
n
%s"
%
(
subject
,
messageText
)
...
...
@@ -131,7 +136,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
Globals
.
Scheduler
.
schedule
(
OneTimeEvent
(
Send
,
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
,
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
,
self
.
timeout
,
headers
[
'from'
],
headers
[
'to'
],
headers
[
'subject'
],
messageText
),
...
...
@@ -140,19 +145,22 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
def
simple_send
(
self
,
mto
,
mfrom
,
subject
,
body
):
body
=
"subject: %s
\
n
\
n
%s"
%
(
subject
,
body
)
SendMail
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
).
send
(
mfrom
=
mfrom
,
mto
=
mto
,
subj
=
subject
,
body
=
body
)
SendMail
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
,
self
.
timeout
).
send
(
mfrom
=
mfrom
,
mto
=
mto
,
subj
=
subject
,
body
=
body
)
class
MailHost
(
Persistent
,
MailBase
):
"persistent version"
def
Send
(
host
,
port
,
localhost
,
from_
,
to
,
subject
,
body
):
SendMail
(
host
,
port
,
localhost
).
send
(
from_
,
to
,
subject
,
body
)
def
Send
(
host
,
port
,
localhost
,
timeout
,
from_
,
to
,
subject
,
body
):
SendMail
(
host
,
port
,
localhost
,
timeout
).
send
(
from_
,
to
,
subject
,
body
)
class
SendMail
:
def
__init__
(
self
,
smtpHost
,
smtpPort
,
localHost
=
"localhost"
):
def
__init__
(
self
,
smtpHost
,
smtpPort
,
localHost
=
"localhost"
,
timeout
=
1
):
self
.
conn
=
socket
(
AF_INET
,
SOCK_STREAM
)
self
.
conn
.
connect
(
smtpHost
,
smtpPort
)
self
.
timeout
=
timeout
self
.
fd
=
self
.
conn
.
fileno
()
self
.
conn
.
send
(
"helo "
+
localHost
+
"
\
r
\
n
"
)
while
1
:
...
...
@@ -163,8 +171,9 @@ class SendMail:
def
getLine
(
self
):
line
=
''
tm
=
self
.
timeout
while
1
:
if
not
select
([
self
.
fd
],[],[],
1.0
)[
0
]:
#check the socket
if
not
select
([
self
.
fd
],[],[],
tm
)[
0
]:
#check the socket
break
data
=
self
.
conn
.
recv
(
1
)
if
(
not
data
)
or
(
data
==
'
\
n
'
):
...
...
@@ -244,6 +253,9 @@ def decapitate(message, **kw):
####################################################################
#
#$Log: MailHost.py,v $
#Revision 1.26 1998/04/08 15:34:52 jeffrey
#Added timeout attribute
#
#Revision 1.25 1998/01/13 23:06:10 brian
#Removed __ac_types__
#
...
...
lib/python/Products/MailHost/addMailHost_form.dtml
View file @
7c5d79a8
...
...
@@ -8,36 +8,41 @@
<FORM ACTION="manage_addMailHost" METHOD="POST">
<TABLE CELLSPACING="2">
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>Id</STRONG></TD
>
<T
H ALIGN="LEFT">Id</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="id" SIZE="40" value="MailHost">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG><EM>Title</EM></STRONG></TD
>
<T
H ALIGN="LEFT"><EM>Title</EM></TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="title" SIZE="40">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>Local Host</STRONG></TD
>
<T
H ALIGN="LEFT">Local Host</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="localhost" SIZE="40" VALUE="<!--#var localhost-->">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>SMTP Host</STRONG></TD
>
<T
H ALIGN="LEFT">SMTP Host</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtp_host" SIZE="40">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>SMTP Port</STRONG></TD
>
<T
H ALIGN="LEFT">SMTP Port</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtp_port:int" SIZE="4" VALUE="25">
</TD>
</TR>
<!--#var smallRolesWidget-->
<TR VALIGN="TOP">
<TH ALIGN="LEFT">Max. Timeout</TH>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="timeout:float" SIZE="4" VALUE="1">
</TD>
</TR>
<TR VALIGN="TOP">
<TD> </TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE=" Add "></TD>
...
...
lib/python/Products/MailHost/manageMailHost.dtml
View file @
7c5d79a8
...
...
@@ -8,33 +8,40 @@
<FORM ACTION="manage_makeChanges" METHOD="POST">
<TABLE CELLSPACING="2">
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>Id</STRONG></TD
>
<T
H ALIGN="LEFT">Id</TH
>
<TD ALIGN="LEFT"><!--#var id--></TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG><EM>Title</EM></STRONG></TD
>
<T
H ALIGN="LEFT"><EM>Title</EM></TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="<!--#var title-->">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>Local Host</STRONG></TD
>
<T
H ALIGN="LEFT">Local Host</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="localHost" SIZE="40" VALUE="<!--#var localHost-->">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>SMTP Host</STRONG></TD
>
<T
H ALIGN="LEFT">SMTP Host</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtpHost" SIZE="40" VALUE="<!--#var smtpHost-->">
</TD>
</TR>
<TR VALIGN="TOP">
<T
D ALIGN="LEFT"><STRONG>SMTP Port</STRONG></TD
>
<T
H ALIGN="LEFT">SMTP Port</TH
>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtpPort:int" SIZE="4" VALUE="<!--#var smtpPort-->">
</TD>
</TR>
<TR VALIGN="TOP">
<TH ALIGN="LEFT">Max. Timeout</TH>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="timeout:float" SIZE="4" VALUE="<!--#var timeout-->">
</TD>
</TR>
<TR VALIGN="TOP">
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Change"></TD>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment