# -*- coding: utf-8 -*-
from email.mime.text import MIMEText
import smtplib
def send ():
server = smtplib.SMTP('smtp.gmail.com' )
server.docmd("EHLO server" )
server.starttls()
server.login('xxx@gmail.com', 'xxx')
msg = MIMEText('<html><body>hello world</body></html>', 'html')
# msg = MIMEText(html, 'html')
# msg['Content-Type' ]='text/plain; charset="utf-8"'
msg['Subject' ] = 'from python'
msg['From' ] = 'xxx@gmail.com'
msg['To' ] = 'xxx@163.com'
server.sendmail('xxx@gmail.com', 'xxx@163.com', msg.as_string())
server.close()
if __name__=="__main__" :
send()
没有评论:
发表评论