Python:简单的邮件发送客户端

#!/usr/bin/env python
# coding:UTF-8


"""
@version: python3.x
@author:曹新健
@contact: [email protected]
@software: PyCharm
@file: 邮件发送.py
@time: 2018/9/10 14:09
"""
import smtplib
from email.mime.text import MIMEText

#SMTP服务器地址
SMTPServer = "smtp.126.com"
#发送者邮件地址
sender = "[email protected]"
#发送者授权密码,注意该密码并不是邮箱登录密码,而是smtp\pop等授权密码
password = "xxx"

#发送内容
mssage = "cxj is a handsome man!"
#转换为邮件文本
mss = MIMEText(mssage)
#标题
mss['Subject'] = "来着超级大帅哥的问候"
#发送者
mss['From'] = sender

#创建SMTP服务器
mailServer = smtplib.SMTP(SMTPServer,25)
#登录邮箱
mailServer.login(sender,password)
#发送邮件
mailServer.sendmail(sender,["[email protected]","[email protected]"],mss.as_string())
#退出邮箱
mailServer.quit()

 

你可能感兴趣的:(Python基础知识,Python基础知识)