import smtplib from email.mime.text import MIMEText mailserver = "smtp.163.com" username_send = 'tccwpl@163.com' password = '邮箱的客户端授权码' username_recv = '996214487@qq.com' mail = MIMEText('彭彭你好哇') mail['Subject'] = '彭彭' mail['From'] = username_send mail['To'] = username_recv smtp = smtplib.SMTP(mailserver,port=25) # smtp=smtplib.SMTP_SSL('smtp.qq.com',port=465) smtp.login(username_send,password) smtp.sendmail(username_send,username_recv,mail.as_string()) smtp.quit() print ('success')