python发送email

来源:互联网 发布:三菱编程实例100 编辑:程序博客网 时间:2024/05/07 13:38
#!/usr/bin/env python#send_simple_email_by_account.py @2014-08-18#author: orangleliuimport smtplibfrom email.mime.text import MIMETextSMTPserver = 'smtp.qq.com'sender = '12345678@qq.com'destination = 'typ123456@qq.com'password = "impasswd"message = 'I send a message by Python. hello'msg = MIMEText(message)msg['Subject'] = 'Test Email by Python'msg['From'] = sendermsg['To'] = destinationmailserver = smtplib.SMTP(SMTPserver, 25)mailserver.login(sender, password)mailserver.sendmail(sender, [destination], msg.as_string())mailserver.quit()print 'send email success'



测试成功

0 0