[Tutor] SMTP

Kent Johnson kent37 at tds.net
Thu Feb 11 22:04:31 CET 2010


On Thu, Feb 11, 2010 at 3:13 PM, Grigor Kolev <grigor.kolev at gmail.com> wrote:
> Hi.
> I try send a mail with smtplib
> Server work with postfix.
> I try it
> ------------------------------------------------
>  import smtplib
>  s=smtplib.SMTP("localhost")
> tolist=['grigor.kolev at gmail.com']
> msg = '''\
>  From: grigor.kolev at gmail.com
> Subject: testin'
> This is a test '''
> s.sendmail("test at local", tolist, msg)
> -------------------------------------------------
> How can i send the file?

I think you need the To: header in the msg, and possibly a blank line
after the headers. See the example here:
http://docs.python.org/library/smtplib.html#smtp-example

Kent


More information about the Tutor mailing list