import smtplib
from email.mime.text import MIMEText
def SendEmail(fromAdd,toAdd,subject,text):
_pwd = "[email protected]" #授权码
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)
原文地址:https://www.cnblogs.com/wangruwei/p/9438711.html