Ernesto wrote:
> Is there a special module for mail ?
> 
> I'd like to send an email [to 'n' unique email addresses] from a python
> script.  

    from email.MIMEText import MIMEText
    import email.Utils
    import smtplib

    # 'users' is a list of email addys.
     for u in users:
        try:
            print "Sending email to ... ", u
            f = "FROM_NAME<[EMAIL PROTECTED]>"
            t = u

            msg = MIMEText("""MESSAGE BODY OF EMAIL""")

            msg["Subject"] = "MESSAGE SUBJECT"
            msg["Message-id"] = email.Utils.make_msgid()
            msg["From"] = f
            msg["To"] = t

            h = "YOUR.SMTP.SERVER"
            s = smtplib.SMTP(h)
            s.sendmail(f, t, msg.as_string())
            s.quit()
        except Exception, e:
             print e
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to