使用python發郵件(帶認證,587端口):python
#!/usr/bin/pythonide
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMETextui
smtpserver='smtp.ming.com'server
username='ming.yang@ming.com'ip
password='xxxxxx'utf-8
sender='ming.yang@ming.com'string
receiver = ['zhi.yang@ming.com','zhi2.yang@ming.com']it
subject='aa'class
msg=MIMEMultipart('mixed')email
msg['Subject']=subject
msg['From']='ming.yang@ming.com'
msg['To']=";".join(receiver)
text="Hi"
text_plain=MIMEText(text,'plain','utf-8')
msg.attach(text_plain)
smtp=smtplib.SMTP()
smtp.connect('smtp.ming.com',587)
smtp.starttls()
smtp.login(username,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()
:wq
執行