subject with smtplib?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Sandys

    subject with smtplib?

    Can you include a subject with sendmail using smtplib?

    When I do this (names changed to protect the innocent):

    import smtplib
    toadr = "me@myisp.c om"
    frmadr = "myhost@myhost. com"
    msg = "this is an important message."
    server = smtplib.SMTP('l ocalhost')
    server.sendmail (frmadr, toadr, msg)
    server.quit()

    I get the important message with a blank subject line.
    It would be really useful to add a subject line,

    sub = "important message"
    server.sendmail (frmadr, toadr, msg, subject=sub)

    I've looked through the documentation and see that
    there is a mail_options but haven't found anything
    about adding a subject.

    Thanks,
    Jeff Sandys
  • Dennis Lee Bieber

    #2
    Re: subject with smtplib?

    On Mon, 23 Feb 2004 23:15:17 GMT, Jeff Sandys <sandysj@juno.c om>
    declaimed the following in comp.lang.pytho n:
    [color=blue]
    > Can you include a subject with sendmail using smtplib?
    >
    > When I do this (names changed to protect the innocent):
    >
    > import smtplib
    > toadr = "me@myisp.c om"
    > frmadr = "myhost@myhost. com"[/color]

    These lines only define the handshaking done with the SMTPd.
    They do not define the "to:" and "from:" headers of most email.
    [color=blue]
    > msg = "this is an important message."[/color]

    msg should include the ENTIRE message, including the headers
    that you expect the receiver to view...


    Look at it this way:

    """
    Date: a long time ago
    From: a.figment@your. imagination
    To: some.unknown.pe rson@a.fictitio us.domain
    Subject: This is junk mail

    Free samples of drug of your choice
    """

    is the "letter"... "From" is the sender address (corporate letterhead),
    "To" is the /inside address/ (look at any book on formatting business
    letters).

    The "frmadr" and "toadr" are the addresses you put on the
    outside of the envelope -- and don't even have to match what is on the
    inside (this is how BCC: works -- the sending program puts the BCC:
    addresses into "toadr" [the envelopes], and then removes the BCC: from
    the letter itself so they don't show).

    --[color=blue]
    > =============== =============== =============== =============== == <
    > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
    > wulfraed@dm.net | Bestiaria Support Staff <
    > =============== =============== =============== =============== == <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

    Comment

    Working...