Automated Email - What did I do wrong here?

Magnus spammers.do.not.bother at void.bogus
Tue Jun 4 11:17:44 EDT 2002


Ken wrote:

> 
> "Ken" <ken at hotmail.com> wrote in message
> news:adifmg$11i5ks$1 at ID-49758.news.dfncis.de...
>> "Ken" <ken at hotmail.com> wrote in message
>> news:adg1do$10nmr5$1 at ID-49758.news.dfncis.de...
>> > How to do automated emailing when results being processed?
>> >
>> > Thanks
>> >
>>
>> What did I do wrong? It crash the program. Without these code, the cgi
>> script works fine. Thanks
>>
>>     fromaddr = 'ken at hotmail.com'
>>     toaddrs = 'ken at hotmail.com'
>>     msg = "testing\n"
>>     server = smtplib.SMTP('smtp.aol.com')
>>     server.sendmail(fromaddr, toaddrs, msg)
>>     server.quit()
>>
> oh...and I did import smtplib...

Try following:

import smtplib
import string, sys

HOST = "smtp.bogus.world"
FROM = "fake at bogus.world"
TO = "fool at bogus.world"
SUBJECT = "Test"
BODY = "Hello........"

body = string.join(("From: %s" % FROM, "To: %s" % TO, "Subject: %s" % 
SUBJECT, "", BODY), "\r\n")
server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO], body)
server.quit()

/Magnus




More information about the Python-list mailing list