mail sending -- smtplib

Kurian Thayil kurianmthayil at gmail.com
Tue Sep 7 00:27:28 EDT 2010


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/20100907/119f381b/attachment.html>


More information about the Python-list mailing list