import smtplib
from email.mime.text import MIMEText
receiver = input('输入接受者邮箱\n')
subject = input('输入标题')
content = input('输入内容')
host = 'smtp.163.com'
user_name = '153******39'
pwd = '******' #163邮箱的授权码
sender = '15383880339@163.com'
message = MIMEText(content,'plain','utf-8')
message['From'] = sender
message['to'] = receiver153******39
message['Subject'] = subject
try:
# 链接163服务器
smtp_obj = smtplib.SMTP(host,25)
# 进行用户密码验证
smtp_obj.login(user_name,pwd)
# 发送邮件
smtp_obj.sendmail(sender,receiver,message.as_string())
print('发送成功')
except smtplib.SMTPException as error:
print(error)
print('发送失败')