欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python使用smtplib模塊通過(guò)gmail實(shí)現(xiàn)郵件發(fā)送的方法

 更新時(shí)間:2015年05月08日 10:33:47   作者:work24  
這篇文章主要介紹了python使用smtplib模塊通過(guò)gmail實(shí)現(xiàn)郵件發(fā)送的方法,涉及Python使用smtplib模塊發(fā)送郵件的相關(guān)技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下

本文實(shí)例講述了python使用smtplib模塊通過(guò)gmail實(shí)現(xiàn)郵件發(fā)送的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
fromaddr = 'fromaddr@gmail.com'
toaddr = 'toaddr@gmail.com'
text = 'test email message sent from Python code'
username = 'fromaddruser'
password = 'fromaddrpassword'
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = 'Test'
msg.attach(MIMEText(text))
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.ehlo()
server.login(username, password)
server.sendmail(fromaddr, toaddr, msg.as_string())
server.quit()

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論