mail sending -- smtplib
Kurian Thayil
kurianmthayil at gmail.com
Wed Sep 8 02:02:10 EDT 2010
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 <kurianmthayil at 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='kurianmthayil at gmail.com'
> toaddr='kurianmthayil at gmail.com'
> print toaddr
> mssg="""From: Kurian Thayil <kurianmthayil at gmail.com>
> To: Kurian Thayil <kurianmthayil at 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100908/e58624b8/attachment-0001.html>
More information about the Python-list
mailing list