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
172bed30
Commit
172bed30
authored
Sep 10, 1997
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The grand "Should Be Working" version...
parent
af37382a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
26 deletions
+20
-26
lib/python/Products/MailHost/MailHost.py
lib/python/Products/MailHost/MailHost.py
+19
-24
lib/python/Products/MailHost/mailHost.dtml
lib/python/Products/MailHost/mailHost.dtml
+1
-2
No files found.
lib/python/Products/MailHost/MailHost.py
View file @
172bed30
from
Globals
import
Persistent
,
HTMLFile
,
HTML
from
socket
import
*
import
Acquisition
,
sys
,
regex
,
string
import
Acquisition
,
sys
,
regex
,
string
,
types
#$Id: MailHost.py,v 1.
4 1997/09/10 15:07:18
jeffrey Exp $
__version__
=
"$Revision: 1.
4
$"
[
11
:
-
2
]
#$Id: MailHost.py,v 1.
5 1997/09/10 18:41:19
jeffrey Exp $
__version__
=
"$Revision: 1.
5
$"
[
11
:
-
2
]
smtpError
=
"SMTP Error"
MailHostError
=
"MailHost Error"
...
...
@@ -16,7 +16,7 @@ def add(self, id='aMailHost', title='Some mail thing', smtp_host=None,
i
.
title
=
title
#title
i
.
_init
(
localHost
=
localhost
,
smtpHost
=
smtp_host
,
smtpPort
=
smtp_port
)
self
.
_setObject
(
id
,
i
)
#register it
return
self
.
manage_main
(
self
,
REQUEST
)
#and whatever this does..
:)
return
self
.
manage_main
(
self
,
REQUEST
)
#and whatever this does.. :)
class
MailHost
(
Persistent
,
Acquisition
.
Implicit
):
...
...
@@ -41,11 +41,8 @@ class MailHost(Persistent, Acquisition.Implicit):
self
.
localHost
=
localHost
self
.
smtpHost
=
smtpHost
self
.
smtpPort
=
smtpPort
return
self
.
manage
(
self
,
REQUEST
)
return
self
.
manage
_main
(
self
,
self
.
REQUEST
)
def
__log
(
self
):
self
.
sentMessages
=
self
.
sentMessages
+
1
def
sendTemplate
(
trueself
,
self
,
messageTemplate
,
statusTemplate
=
None
,
mto
=
None
,
mfrom
=
None
,
REQUEST
):
'render a mail template, then send it...'
...
...
@@ -66,13 +63,13 @@ class MailHost(Persistent, Acquisition.Implicit):
subj
=
headers
[
'subject'
],
body
=
messageText
)
self
.
__log
()
return
(
"sent"
,
"sent..."
)
#return getattr(self,statusTemplate)(self, self.REQUEST,
# messageText=message)
if
statusTemplate
:
return
getattr
(
self
,
statusTemplate
)(
self
,
self
.
REQUEST
,
messageText
=
message
)
else
:
return
"SEND OK"
def
send
(
self
,
messageText
,
mto
=
None
,
mfrom
=
None
):
'send a rendered message'
headers
,
message
=
newDecapitate
(
messageText
)
if
mto
:
headers
[
'to'
]
=
mto
if
mfrom
:
headers
[
'from'
]
=
mfrom
...
...
@@ -84,19 +81,11 @@ class MailHost(Persistent, Acquisition.Implicit):
SendMail
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
).
send
(
mfrom
=
headers
[
'from'
],
mto
=
headers
[
'to'
],
subj
=
headers
[
'subject'
],
body
=
messageText
)
self
.
__log
()
return
(
"sent"
,
"sent..."
)
#return getattr(self,statusTemplate)(self, self.REQUEST,
# messageText=message)
def
simple_send
(
self
,
mto
,
mfrom
,
subject
,
body
):
'like the simplist send or something'
body
=
"subject: %s
\
n
\
n
%s"
%
(
subject
,
body
)
SendMail
(
self
.
smtpHost
,
self
.
smtpPort
,
self
.
localHost
).
send
(
mfrom
=
mfrom
,
mto
=
mto
,
subj
=
subject
,
body
=
body
)
self
.
__log
()
return
(
"sent"
,
"sent..."
)
class
SendMail
:
def
__init__
(
self
,
smtpHost
,
smtpPort
,
localHost
=
"localhost"
):
...
...
@@ -116,7 +105,7 @@ class SendMail:
def
send
(
self
,
mfrom
,
mto
,
subj
,
body
):
self
.
conn
.
send
(
"mail from:<%s>
\
n
"
%
mfrom
)
self
.
_check
()
if
type
(
mto
)
==
type
([
1
,
2
])
:
if
type
(
mto
)
in
[
types
.
ListType
,
types
.
TupleType
]
:
for
person
in
mto
:
self
.
conn
.
send
(
"rcpt to:<%s>
\
n
"
%
person
)
self
.
_check
()
...
...
@@ -147,6 +136,12 @@ def newDecapitate(message):
headerDict[string.lower(header_re.group('
headerName
'))] =
\
string.strip(header_re.group('
headerText
'))
linecount=linecount+1
if headerDict.has_key('
to
'):
headerDict['
to
']=map(
lambda x: string.strip(x),
string.split(headerDict['
to
'], '
,
')
)
body=string.join(maxwell[linecount:],'
\
n
')
return headerDict, body
...
...
@@ -198,6 +193,6 @@ def decapitate(message,
return (headerDict, body)
#$Log: MailHost.py,v $
#Revision 1.
4 1997/09/10 15:07:18
jeffrey
#
and converted tabs back to spaces in source.. sorry!
#Revision 1.
5 1997/09/10 18:41:19
jeffrey
#
The grand "Should Be Working" version...
##
\ No newline at end of file
lib/python/Products/MailHost/mailHost.dtml
View file @
172bed30
...
...
@@ -6,14 +6,13 @@
<BODY
BGCOLOR=
"#FFFFFF"
>
<TABLE>
<TR>
<TD
ALIGN=
RIGHT
><H3><I>
A
ll about me
:
</I></H3></TD>
<TD
ALIGN=
RIGHT
><H3><I>
A
bout MailHost
<U>
<!--#var title-->
</U>
:
</I></H3></TD>
</TR>
<TR>
<TD
BGCOLOR=
"#CCCCCC"
>
<B>
Title:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var title-->
</FONT><BR>
<B>
Mail Host:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var smtpHost-->
</FONT><BR>
<B>
Mail Port:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var smtpPort-->
</FONT><BR>
<B>
Messages sent:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var sentMessages-->
</FONT>
</TD>
</TR>
</TABLE>
...
...
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