Commit d4d0ea4f authored by 's avatar

Merged MailHost.send fixes from 2.2 branch

parent 25080b96
......@@ -84,8 +84,8 @@
##############################################################################
"""SMTP mail objects
$Id: MailHost.py,v 1.53 2000/06/19 18:51:58 brian Exp $"""
__version__ = "$Revision: 1.53 $"[11:-2]
$Id: MailHost.py,v 1.54 2000/06/19 19:52:26 brian Exp $"""
__version__ = "$Revision: 1.54 $"[11:-2]
from Globals import Persistent, HTMLFile, HTML, MessageDialog
from smtplib import SMTP
......@@ -122,6 +122,8 @@ def add(self, id, title='', smtp_host=None,
if REQUEST is not None:
REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
import pdb
class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
'a mailhost...?'
meta_type='Mail Host'
......@@ -199,15 +201,17 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
def send(self, messageText, mto=None, mfrom=None, subject=None,
encode=None):
# pdb.set_trace()
headers = extractheaders(messageText)
if not headers['subject']:
messageText="subject: %s\n%s" % (subject or '[No Subject]',
messageText="subject: %s\n\n%s" % (subject or '[No Subject]',
messageText)
if mto:
if type(mto) is type('s'):
mto=map(string.strip, string.split(mto,','))
headers['to'] = filter(truth, mto)
headers['to'] = filter(None, mto)
if mfrom:
headers['from'] = mfrom
......@@ -285,5 +289,5 @@ def extractheaders(message):
hd['to'].append(addr)
hd['from']=mo.getaddr('from')[1]
hd['subject']=mo.getheader('subject') or "No Subject"
hd['subject']=mo.getheader('subject') or ''
return hd
......@@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__rcs_id__='$Id: SendMailTag.py,v 1.7 1999/11/03 16:09:14 brian Exp $'
__version__='$Revision: 1.7 $'[11:-2]
__rcs_id__='$Id: SendMailTag.py,v 1.8 2000/06/19 19:52:26 brian Exp $'
__version__='$Revision: 1.8 $'[11:-2]
from MailHost import MailBase
from DocumentTemplate.DT_Util import *
......@@ -94,7 +94,7 @@ import string
class SendMailTag:
'''the send mail tag, used like thus:
<dtml-sendmail someMailHostID>
<dtml-sendmail mailhost="someMailHostID">
to: person@their.machine.com
from: me@mymachine.net
subject: just called to say...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment