python3 发送邮件

import smtplib
from email.mime.text import MIMEText
def SendEmail(fromAdd,toAdd,subject,text):

_pwd = "Yeer2016@sudai" #授权码

msg = MIMEText(text)
msg["Subject"] = subject
msg["From"] = fromAdd
msg["To"] = toAdd
try:
s = smtplib.SMTP_SSL("smtp.sudaizhijia.com", 465)
s.login(fromAdd, _pwd)
s.sendmail(fromAdd, toAdd, msg.as_string())
s.quit()
print ("Success!")
except smtplib.SMTPException:
print('Falied!')
if __name__=='__main__':
from_="[email protected]" #你的邮箱 发件地址
to_sender_address_list = ["11.qq,com","33.qq.com"] #收件地址
subject = input('Please input title:') #邮件标题
text= input('Please input Content:') #邮件内容

for i in to_sender_address_list:
SendEmail(from_,i,subject,text)

猜你喜欢

转载自www.cnblogs.com/wangruwei/p/9438711.html
今日推荐