def ba_smtp_sendEmail(email_title, email_content, email_type, email_sender, email_receiver, email_host, email_user, email_pwd):
# ??, ??, ??
message = MIMEText(email_content, email_type, 'utf-8')
message['From'] = '{}'.format(email_sender)
message['To'] = ','.join(email_receiver)
message['Subject'] = email_title
try:
# ??SSL??, ?????465
smtpObj = smtplib.SMTP_SSL(email_host, 465)
# ????
smtpObj.login(email_user, email_pwd)
# ??
smtpObj.sendmail(email_sender, email_receiver, message.as_string())
print('??????!')
except smtplib.SMTPException as e:
print("Error: ??????")
print(e)
评论列表
文章目录