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
efb60e83
Commit
efb60e83
authored
Jan 15, 2002
by
Jens Vagelpohl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out the actual sending of mail into a separate method
parent
ed8ccac4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
10 deletions
+27
-10
lib/python/Products/MailHost/MailHost.py
lib/python/Products/MailHost/MailHost.py
+27
-10
No files found.
lib/python/Products/MailHost/MailHost.py
View file @
efb60e83
...
...
@@ -12,8 +12,8 @@
##############################################################################
"""SMTP mail objects
$Id: MailHost.py,v 1.6
7 2002/01/15 04:31:24
jens Exp $"""
__version__
=
"$Revision: 1.6
7
$"
[
11
:
-
2
]
$Id: MailHost.py,v 1.6
8 2002/01/15 04:45:13
jens Exp $"""
__version__
=
"$Revision: 1.6
8
$"
[
11
:
-
2
]
from
Globals
import
Persistent
,
DTMLFile
,
InitializeClass
from
smtplib
import
SMTP
...
...
@@ -70,11 +70,13 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
self
.
smtp_host
=
str
(
smtp_host
)
self
.
smtp_port
=
str
(
smtp_port
)
# staying for now... (backwards compatibility)
def
_init
(
self
,
smtp_host
,
smtp_port
):
self
.
smtp_host
=
smtp_host
self
.
smtp_port
=
smtp_port
security
.
declareProtected
(
'Change configuration'
,
'manage_makeChanges'
)
def
manage_makeChanges
(
self
,
title
,
smtp_host
,
smtp_port
,
REQUEST
=
None
):
'make the changes'
...
...
@@ -94,6 +96,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
,
manage_tabs_message
=
msg
)
security
.
declareProtected
(
use_mailhost_services
,
'sendTemplate'
)
def
sendTemplate
(
trueself
,
self
,
messageTemplate
,
statusTemplate
=
None
,
mto
=
None
,
mfrom
=
None
,
...
...
@@ -109,8 +112,8 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
if
not
headers
.
has_key
(
requiredHeader
):
raise
MailHostError
,
"Message missing SMTP Header '%s'"
\
%
requiredHeader
mailserver
=
SMTP
(
trueself
.
smtp_host
,
trueself
.
smtp_port
)
mailserver
.
sendmail
(
headers
[
'from'
],
headers
[
'to'
],
messageText
)
self
.
_send
(
headers
,
messageText
)
if
not
statusTemplate
:
return
"SEND OK"
...
...
@@ -120,6 +123,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
except
:
return
"SEND OK"
security
.
declareProtected
(
use_mailhost_services
,
'send'
)
def
send
(
self
,
messageText
,
mto
=
None
,
mfrom
=
None
,
subject
=
None
,
encode
=
None
):
...
...
@@ -148,8 +152,9 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
raise
MailHostError
,
"Message missing SMTP Header '%s'"
\
%
requiredHeader
messageText
=
_encode
(
messageText
,
encode
)
smtpserver
=
SMTP
(
self
.
smtp_host
,
self
.
smtp_port
)
smtpserver
.
sendmail
(
headers
[
'from'
],
headers
[
'to'
],
messageText
)
self
.
_send
(
headers
,
messageText
)
security
.
declareProtected
(
use_mailhost_services
,
'scheduledSend'
)
def
scheduledSend
(
self
,
messageText
,
mto
=
None
,
mfrom
=
None
,
subject
=
None
,
...
...
@@ -175,15 +180,27 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
raise
MailHostError
,
"Message missing SMTP Header '%s'"
\
%
requiredHeader
messageText
=
_encode
(
messageText
,
encode
)
smtpserver
=
SMTP
(
self
.
smtp_host
,
self
.
smtp_port
)
smtpserver
.
sendmail
(
headers
[
'from'
],
headers
[
'to'
],
messageText
)
self
.
_send
(
headers
,
messageText
)
security
.
declareProtected
(
use_mailhost_services
,
'simple_send'
)
def
simple_send
(
self
,
mto
,
mfrom
,
subject
,
body
):
body
=
"from: %s
\
n
to: %s
\
n
subject: %s
\
n
\
n
%s"
%
(
mfrom
,
mto
,
subject
,
body
)
mailserver
=
SMTP
(
self
.
smtp_host
,
self
.
smtp_port
)
mailserver
.
sendmail
(
mfrom
,
mto
,
body
)
headers
=
{}
headers
[
'from'
]
=
mfrom
headers
[
'to'
]
=
mto
self
.
_send
(
headers
,
body
)
security
.
declarePrivate
(
'_send'
)
def
_send
(
self
,
headers
,
body
):
""" Send the message """
smtpserver
=
SMTP
(
self
.
smtp_host
,
self
.
smtp_port
)
smtpserver
.
sendmail
(
headers
[
'from'
],
headers
[
'to'
],
body
)
smtpserver
.
quit
()
InitializeClass
(
MailBase
)
...
...
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