1. 程式人生 > >發郵件

發郵件

smtplib utf-8 str port text pre xxxxxx serve gin

def email():
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
msg=MIMEText(‘老婆,我愛你‘,‘plain‘,‘utf-8‘)
msg[‘From‘]=formataddr([‘tf‘,‘[email protected]‘])
msg[‘To‘]=formataddr([‘vvv‘,‘[email protected]‘])
msg[‘Subject‘]=‘主題‘

server=smtplib.SMTP_SSL(‘smtp.qq.com‘,465)
server.login("[email protected]","xxxxxx")
server.sendmail(‘[email protected]‘,[‘[email protected]‘,],msg.as_string())
server.quit()
email()

發郵件