Using smtplib

Jose, Cindy jose at
Fri Mar 10 19:07:08 CET 2000

This is a code fragment we use:

    to = 'somebody at'
    sender = 'jose at'
    test_msg = 'Subject: DocuShare Mail Check\n\nA test message from the
DocuShare subscription service.\n'
    port = 25    # optional param, 25 is default
    gateway = ''
        mailer = smtplib.SMTP(gateway, port)
            mailer.sendmail(sender, [to], test_msg)

Which results in the following message:
From: jose at [mailto:jose at] 
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

> -----Original Message-----
> From: David Boddie [mailto:davidb at]
> Sent: Friday, March 10, 2000 9:12 AM
> To: python-list at
> 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:

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 Boddie
Solar MHD Theory Group, St Andrews


More information about the Python-list mailing list