Using smtplib
Jose, Cindy
jose at pahv.xerox.com
Fri Mar 10 13:07:08 EST 2000
This is a code fragment we use:
to = 'somebody at wherever.com'
sender = 'jose at pahv.xerox.com'
test_msg = 'Subject: DocuShare Mail Check\n\nA test message from the
DocuShare subscription service.\n'
port = 25 # optional param, 25 is default
gateway = 'mailhost.wherever.com'
try:
mailer = smtplib.SMTP(gateway, port)
try:
mailer.sendmail(sender, [to], test_msg)
mailer.quit()
except:
...
except:
...
Which results in the following message:
------------------
From: jose at pahv.xerox.com [mailto:jose at pahv.xerox.com]
Sent: None
Subject: DocuShare Mail Check
A test message from the DocuShare subscription service.
------------------
I don't know why no To: field shows up, but it does arrive at the to
address.
> -----Original Message-----
> From: David Boddie [mailto:davidb at dcs.st-and.ac.uk]
> Sent: Friday, March 10, 2000 9:12 AM
> To: python-list at python.org
> Subject: Re: Using smtplib
>
>
> On Fri, 10 Mar 2000, Pieter Claerhout wrote:
>
> > does anyone has an example on how to send an email using the
> > smtplib? I'm able to send an email, but I can't figure out how to
> > fill in the from, subject and to fields.
>
> The documentation for this module contains an example:
>
http://www.python.org/doc/current/lib/SMTP-example.html
When reading e-mail which was sent by this example, only the "From:" and
"Date:" headers seem to be generated. As far as I can tell, if you want
"To:" and "Subject:" headers to appear in the e-mail then you have to
include them in the message body. The manual suggests that you also
include the "From:" header as well.
Hope this helps,
David
--
David Boddie
Solar MHD Theory Group, St Andrews
http://www-solar.mcs.st-and.ac.uk/~davidb/index.html
--
http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list