Specifying subject using smtplib

Jim Severino jimsev at my-deja.com
Fri Feb 11 14:45:02 CET 2000


Fredrik

Thank you for your totally correct reply. I just bought your book from
Fatbrain, and recommend it to anyone who programs (or dabbles, as I do)
in Python.

Jim

In article <ermn4.5258$al3.67922 at newsc.telia.net>,
  "Fredrik Lundh" <effbot at telia.com> wrote:
> Jim Severino <jimsev at my-deja.com> wrote:
> > In the smtplib module, the SMTP object's method "sendmail" is
formatted
> > like so:
> >
> > sendmail (from_addr, to_addrs, msg[, mail_options, rcpt_options])
> >
> > Can anyone tell me where you specify the message's subject?
>
> in the message itself.
>
> from_addr and to_addrs are commands to the
> mail transport; everything that you want to go
> into the message header should be explicitly put
> into the message.
>
> (the mail transport agent may rewrite some of
> the headers, but don't rely on that...)
>
> here's an example from the eff-bot guide (see
> footer for more info):
>
> # File: smtplib-example-1.py
>
> import smtplib
> import string, sys
>
> HOST = "localhost"
> FROM = "effbot at spam.egg"
> TO = "fredrik at spam.egg"
>
> SUBJECT = "for your information!"
>
> BODY = "next week: how to fling an otter"
>
> body = string.join((
>     "From: %s" % FROM,
>     "To: %s" % TO,
>     "Subject: %s" % SUBJECT,
>     "",
>     BODY), "\r\n")
>
> print body
>
> server = smtplib.SMTP(HOST)
> server.sendmail(FROM, [TO], body)
> server.quit()
>
> </F>
>
> <!-- (the eff-bot guide to) the standard python library:
> http://www.pythonware.com/people/fredrik/librarybook.htm
> -->
>
>

--
-------------------------
I'll check my my-deja email as often as I can.
Well, whenever I remember, anyways.


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list