python3 发送邮件

时间:2023-02-02 22:29:59

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_="tech-report@sudaizhijia.com" #你的邮箱 发件地址
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)