python送信メールモジュール

814 ワード

#!/usr/bin/python
import smtplib
import string

HOST="smtp.gmail.com" //  SMTP  
tolist=['[email protected]','[email protected]','[email protected]'] //     
FROM="[email protected]" //     
SUBJECT="Python Module stmplib test email" //    
bodys=""" //  
This is a test mail please delete this mail thank you """
BODY = string.join((
        "From: %s" % FROM,
        "To: %s" % ';'.join(tolist),
        "Subject: %s" % SUBJECT,
        "",
        bodys
        ),"\r
") server=smtplib.SMTP() server.connect(HOST,"25") server.starttls() server.login("[email protected]","emailpassword") // server.sendmail(FROM,tolist,BODY) // server.quit()