smtp module

Michael P. Reilly arcege at shore.net
Sat Jun 5 19:16:56 EDT 1999


Philip C. <pjc_2 at geocities.com> wrote:
: I have pretty much figured out how to use the module but I can't seem
: set the subject or the from of the bcc etc....

: please tell me how to do it?

You need to include the SMTP headers in the message itself.

  from smtplib import SMTP
  fromaddr = 'arcege at shore.net'
  toaddr = 'python-list at python.org'
  message = '''\
  From: %(fromaddr)s
  To: %(toaddr)s
  Subject: Re: smtp module
  Bcc: %(fromaddr)s
  Reply-to: %(fromaddr)s

  Philip C. <pjc_2geocities.com> wrote:
  : I have pretty much figured out how to use the module but I can't seem
  : set the subject or the from of the bcc etc....

  : please tell me how to do it?
  ''' % locals()

  SMTP('mailhost').sendmail(fromaddr, [toaddr], message)

The protocol for SMTP requires that the headers are included.

  -Arcege





More information about the Python-list mailing list