smtplib发送邮件

import smtplib

from email.mime.text import MIMEText
from email.utils import formataddr

msg =MIMEText('正文:来自python的邮件','plain','utf-8')
msg['From'] = formataddr(['王恩道','[email protected]'])
msg['To'] = formataddr(['李慧钦','[email protected]'])
msg['Subject'] = '主题内容'

server=smtplib.SMTP('mail.crv.com.cn',25)
server.login('[email protected]','密码')
server.sendmail('[email protected]',['[email protected]'],msg.as_string())
server.quit()

你可能感兴趣的:(smtplib发送邮件)