1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#coding=utf8 import smtplib from email.mime.text import MIMEText from email.header import Header msg = MIMEText("Hello, send by python", "plain", "utf-8") msg['From'] = Header("Noreply", "utf-8") msg['Subject'] = Header("Yeeeeeeeeeeha", "utf-8") try: emailServer = smtplib.SMTP("mail.xxx.com", 25) emailServer.set_debuglevel(1) emailServer.login('username', 'password') emailServer.sendmail('noreply@xxx.com', ['xxxxxx@qq.com'], msg.as_string()) emailServer.quit() except smtplib.SMTPException: print("Error: Send email error") |