用python发邮件:
代码:
import os
#import common
title = 'hello test'
content = 'this is the test content'
sender = 'huangzhiqiang03@baidu.com'
receivers = 'huangzhiqiang@baidu.com'
cc_receivers = 'huangzhiqiang03@baidu.com'
append_files = ''
date = ''
cmd='(echo "Hi,"; echo "{t}"; echo "{c}"; echo "{d}";) | mutt -e "my_hdr from:{s}"' \
' -e "my_hdr content-type:text/html" -s "{t}" "{r}" -c "{cc}" '.format(
t=title, c=content, d=date,s=sender,r=receivers, cc=cc_receivers,)
try:
os.system(cmd)
except Exception as e:
err_msg='send mail failed'+str(e)
print err_msg
其中mutt是linux下的一个下的一个email程序。