我有一个HTML码@http://pastie.org/8289257在一个文本文件"gerrit.txt“,这将创建一个表的一些内容,我转换的文本文件为.htm文件,并打开它的输出看起来非常好,这告诉我的HTML代码是好的,但当我电子邮件(使用outlook)它使用下面的代码,表格有时会被搞乱。我需要关于我可以发送电子邮件的其他方式的想法?我尝试了SMTP,如下所示,似乎不起作用…
from email.mime.text import MIMEText
from smtplib import SMTP
def email (body,subject):
msg = MIMEText("%s" % body)
msg['Content-Type'] = "text/html; charset=UTF8"
msg['Subject'] = subject
s = SMTP('localhost',25)
s.sendmail('userid@company.com', ['userid2@company.com'],msg=msg.as_string())
def main ():
# open gerrit.txt and read the content into body
with open('gerrit.txt', 'r') as f:
body = f.read()
subject = "test email"
email(body,subject)
print "Done"
if __name__ == '__main__':
main()https://stackoverflow.com/questions/18561475
复制相似问题