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
47498241
Commit
47498241
authored
Jan 05, 1998
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split out the SendMail tag machinery into new module
parent
209d8292
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
94 deletions
+112
-94
lib/python/Products/MailHost/MailHost.py
lib/python/Products/MailHost/MailHost.py
+5
-91
lib/python/Products/MailHost/SendMailTag.py
lib/python/Products/MailHost/SendMailTag.py
+104
-0
lib/python/Products/MailHost/__init__.py
lib/python/Products/MailHost/__init__.py
+3
-3
No files found.
lib/python/Products/MailHost/MailHost.py
View file @
47498241
...
...
@@ -9,8 +9,8 @@ import Globals
from
Scheduler.OneTimeEvent
import
OneTimeEvent
from
ImageFile
import
ImageFile
#$Id: MailHost.py,v 1.2
3 1998/01/02 22:55:44
jeffrey Exp $
__version__
=
"$Revision: 1.2
3
$"
[
11
:
-
2
]
#$Id: MailHost.py,v 1.2
4 1998/01/05 19:34:12
jeffrey Exp $
__version__
=
"$Revision: 1.2
4
$"
[
11
:
-
2
]
smtpError
=
"SMTP Error"
MailHostError
=
"MailHost Error"
...
...
@@ -241,100 +241,14 @@ def decapitate(message, **kw):
from DocumentTemplate.DT_Util import *
from DocumentTemplate.DT_String import String
class SendMailTag:
'''the send mail tag, used like thus:
<!--#sendmail someMailHostID-->
to: person@their.machine.com
from: me@mymachine.net
subject: just called to say...
boy howdy!
<!--#/sendmail-->
Text between the sendmail and /sendmail tags is processed
by the MailHost machinery and delivered. There must be at least
one blank line seperating the headers (to/from/etc..) from the body
of the message.
Instead of specifying a MailHost, an smtphost may be specified
ala '
smtphost
=
"mail.mycompany.com"
port
=
25
' (port defaults to 25
automatically). Other parameters are
* mailto -- person (or comma-seperated list of persons) to send the
mail to. If not specified, there **must** be a to: header in the
message.
* mailfrom -- person sending the mail (basically who the recipient can
reply to). If not specified, there **must** be a from: header in the
message.
* subject -- optional subject. If not specified, there **must** be a
subject: header in the message.
'''
name='
sendmail
'
blockContinuations=()
def __init__(self, blocks):
tname, args, section=blocks[0]
args=parse_params(args, mailhost=None, mailto=None, mailfrom=None,
subject=None, smtphost=None, port='
25
')
for key in ('
mailto
', '
mailfrom
', '
subject
', '
smtphost
', '
port
'):
if not args.has_key(key):args[key]=''
smtphost=None
has_key=args.has_key
if has_key('
mailhost
'): mailhost=args['
mailhost
']
elif has_key('
smtphost
'): mailhost=smtphost=args['
smtphost
']
elif has_key(''): mailhost=args['
mailhost
']=args['']
else: raise MailHostError, '
No
mailhost
was
specified
in
tag
'
if not smtphost:
self.__name__=self.mailhost=mailhost
self.smtphost=None
else:
self.__name__=self.smtphost=smtphost
self.mailhost=None
self.section=section
self.args=args
self.mailto=args['
mailto
']
self.mailfrom=args['
mailfrom
']
self.subject=None or args['
subject
']
if args['
port
'] and type(args['
port
']) is type('
s
'):
self.port=args['
port
']=string.atoi(args['
port
'])
elif args['
port
']=='':
self.port=args['
port
']=25
else:
self.port=args['
port
']
def render(self, md):
args=self.args
has_key=args.has_key
if self.mailhost:
mhost.send(self.section(md.this, md), self.mailto, self.mailfrom,
self.subject)
elif self.smtphost:
mhost=MailBase()
mhost._init(localHost=gethostname(), smtpHost=self.smtphost,
smtpPort=self.port)
mhost.send(self.section(md.this, md), self.mailto, self.mailfrom,
self.subject)
return '
'
__call__=render
String.commands['
sendmail
']=SendMailTag
####################################################################
#
#$Log: MailHost.py,v $
#Revision 1.24 1998/01/05 19:34:12 jeffrey
#split out the SendMail tag machinery into new module
#
#Revision 1.23 1998/01/02 22:55:44 jeffrey
#minor cleanups, added SendMailTag class for DTML.
#
...
...
lib/python/Products/MailHost/SendMailTag.py
0 → 100644
View file @
47498241
__rcs_id__
=
'$Id: SendMailTag.py,v 1.1 1998/01/05 19:34:31 jeffrey Exp $'
__version__
=
'$Revision: 1.1 $'
[
11
:
-
2
]
from
MailHost
import
MailBase
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_String
import
String
from
socket
import
gethostname
import
string
class
SendMailTag
:
'''the send mail tag, used like thus:
<!--#sendmail someMailHostID-->
to: person@their.machine.com
from: me@mymachine.net
subject: just called to say...
boy howdy!
<!--#/sendmail-->
Text between the sendmail and /sendmail tags is processed
by the MailHost machinery and delivered. There must be at least
one blank line seperating the headers (to/from/etc..) from the body
of the message.
Instead of specifying a MailHost, an smtphost may be specified
ala 'smtphost="mail.mycompany.com" port=25' (port defaults to 25
automatically). Other parameters are
* mailto -- person (or comma-seperated list of persons) to send the
mail to. If not specified, there **must** be a to: header in the
message.
* mailfrom -- person sending the mail (basically who the recipient can
reply to). If not specified, there **must** be a from: header in the
message.
* subject -- optional subject. If not specified, there **must** be a
subject: header in the message.
'''
name
=
'sendmail'
blockContinuations
=
()
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
mailhost
=
None
,
mailto
=
None
,
mailfrom
=
None
,
subject
=
None
,
smtphost
=
None
,
port
=
'25'
)
for
key
in
(
'mailto'
,
'mailfrom'
,
'subject'
,
'smtphost'
,
'port'
):
if
not
args
.
has_key
(
key
):
args
[
key
]
=
''
smtphost
=
None
has_key
=
args
.
has_key
if
has_key
(
'mailhost'
):
mailhost
=
args
[
'mailhost'
]
elif
has_key
(
'smtphost'
):
mailhost
=
smtphost
=
args
[
'smtphost'
]
elif
has_key
(
''
):
mailhost
=
args
[
'mailhost'
]
=
args
[
''
]
else
:
raise
MailHostError
,
'No mailhost was specified in tag'
if
not
smtphost
:
self
.
__name__
=
self
.
mailhost
=
mailhost
self
.
smtphost
=
None
else
:
self
.
__name__
=
self
.
smtphost
=
smtphost
self
.
mailhost
=
None
self
.
section
=
section
self
.
args
=
args
self
.
mailto
=
args
[
'mailto'
]
self
.
mailfrom
=
args
[
'mailfrom'
]
self
.
subject
=
None
or
args
[
'subject'
]
if
args
[
'port'
]
and
type
(
args
[
'port'
])
is
type
(
's'
):
self
.
port
=
args
[
'port'
]
=
string
.
atoi
(
args
[
'port'
])
elif
args
[
'port'
]
==
''
:
self
.
port
=
args
[
'port'
]
=
25
else
:
self
.
port
=
args
[
'port'
]
def
render
(
self
,
md
):
args
=
self
.
args
has_key
=
args
.
has_key
if
self
.
mailhost
:
mhost
.
send
(
self
.
section
(
md
.
this
,
md
),
self
.
mailto
,
self
.
mailfrom
,
self
.
subject
)
elif
self
.
smtphost
:
mhost
=
MailBase
()
mhost
.
_init
(
localHost
=
gethostname
(),
smtpHost
=
self
.
smtphost
,
smtpPort
=
self
.
port
)
mhost
.
send
(
self
.
section
(
md
.
this
,
md
),
self
.
mailto
,
self
.
mailfrom
,
self
.
subject
)
return
' '
__call__
=
render
String
.
commands
[
'sendmail'
]
=
SendMailTag
#############################################################
#
# $Log: SendMailTag.py,v $
# Revision 1.1 1998/01/05 19:34:31 jeffrey
# split out the SendMail tag machinery into new module
#
#
lib/python/Products/MailHost/__init__.py
View file @
47498241
...
...
@@ -8,10 +8,10 @@
#
##############################################################################
__doc__
=
'''MailHost Product Initialization
$Id: __init__.py,v 1.
5 1997/12/19 21:46:37
jeffrey Exp $'''
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
$Id: __init__.py,v 1.
6 1998/01/05 19:34:12
jeffrey Exp $'''
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
import
MailHost
import
MailHost
,
SendMailTag
from
ImageFile
import
ImageFile
meta_types
=
{
'name'
:
'Mail Host'
,
...
...
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