使用python发邮件(带认证,587端口):

vi mail.py

#!/usr/bin/python

-- coding:UTF-8 --

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

smtpserver='smtp.ming.com'

username='[email protected]'

password='xxxxxx'

sender='[email protected]'

receiver = ['[email protected]','[email protected]']

subject='aa'

msg=MIMEMultipart('mixed')

msg['Subject']=subject

msg['From']='[email protected]'

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

执行

python mail.py