def mail_client(host, port, fromAddress, password, toAddress, subject, body):
msg = MIMEMultipart()
msg['From'] = fromAddress
msg['To'] = toAddress
msg['Subject'] = subject
message = body
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP(host,port)
# Identify to the SMTP Gmail Client
mailserver.ehlo()
# Secure with TLS Encryption
mailserver.starttls()
# Reidentifying as an encrypted connection
mailserver.ehlo()
mailserver.login(fromAddress, password)
mailserver.sendmail(fromAddress,toAddress,msg.as_string())
print ("Email sent from:", fromAddress)
mailserver.quit()
5_10_secure_mail_client.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录