Got it fixed. It was a very silly mistake. mssg variable had each line with indent. Removed the indent and it worked.
Regards, Kurian Thayil. On Tue, Sep 7, 2010 at 9:57 AM, Kurian Thayil <kurianmtha...@gmail.com>wrote: > Hi All, > > I am a newbie in python. Just 2-3 days old wanting to learn this amazing > programming language. I was trying to send mails using smtplib module, so > did some google and found a code snippet. The mail gets sent, but doesn't > come in the right format when a for-loop is introduced (Not MIME standard?). > Without the for-loop the script works fine. Can anyone advice? > * > #!/usr/bin/env python > > import smtplib > > for i in range(1,5): > print "I is ",i > fromaddr='kurianmtha...@gmail.com' > toaddr='kurianmtha...@gmail.com' > print toaddr > mssg="""From: Kurian Thayil <kurianmtha...@gmail.com> > To: Kurian Thayil <kurianmtha...@gmail.com> > MIME-Version: 1.0 > Content-type: text/html > Subject: 12345 -- Reloaded :) > > <b>Hey dude.. how are you????</b> > > <br><br><br><br> > Regards, > <br><br> > Kurian > """ > print "message is ",mssg > > smail=smtplib.SMTP('smtp.gmail.com',587) > > smail.ehlo() > smail.starttls() > smail.ehlo() > smail.login(fromaddr,'***********') > > smail.sendmail(fromaddr,toaddr,mssg) > print "Over" > * > > Regards, > > Kurian Thayil. >
-- http://mail.python.org/mailman/listinfo/python-list