[Zope] Getting email fields right
flynt
flynt@gmx.ch
Wed, 28 Nov 2001 13:13:50 +0100
Bruce Eckel wrote:
>
> I'm using the MailHost to send email from within an external
> method. I've tried a number of different combinations, including
> something as elaborate as this:
>
> self.MailHost.send("This is a test", # Body
> "To: Bruce Eckel <Bruce@EckelObjects.com>",
> "From: Bruce Eckel <Bruce@EckelObjects.com>",
> "Test Email") # Subject
>
> However, I can't seem to get the "to" and "from" fields to show up
> right in the resulting email. All I end up with is a 'to' field of
> Bruce@EckelObjects.com
> and an empty 'from' field.
>
> I suspect others have done this before and solved the problem. Or
> will want to :-)
Hi Bruce
With the help of Lundh's *Python Standard Library* I got to the
following. This is in the external method:
import string
def testmail(self):
message = "This is a test"
mto = "Bruce@EckelObjects.com"
mfrom = "Bruce@EckelObjects.com"
subject = "Test Email"
encode = None
body = string.join((
"From: %s" % mfrom,
"To: %s" % mto,
"Subject: %s" % subject,
"",
message), "\r\n")
self.MailHost.send(body, [mto], mfrom, subject, encode)
Greetings
--- Flynt