smtp: Use Python to send e-mail

 

 

#-*-coding: utf-8 -*-

import smtplib
from email.mime.text import MIMEText
def sendmail():
try:
smtp=smtplib.SMTP(HOST,PORT)
smtp.login(USER,PASSWORD)
smtp.sendmail('hello'+'<'+USER+'>',TO,MSG)
smtp.quit()
print 'email send success'
except Exception,e:
print e
print 'email send fail'
HOST='smtp.163.com'
PORT='25'
TIMEOUT=30
USER='17606719860@163.com'
PREFIX='163.com'
PASSWORD='cc1842'
TO='chen.chen@ecitele.com'
MSG='python send email test'

if __name__=='__main__':sendmail()

 

posted @ 2016-10-28 13:12  yushangcc  阅读(89)  评论(0编辑  收藏  举报