我已经在我的邮件服务器上安装了 iRedEmail。现在它有默认证书。当我使用普通的电子邮件客户端时,它要求我信任邮件服务器的证书,然后它开始从邮件服务器接收/发送电子邮件
但是,如果我编写自己的 python 程序来发送电子邮件,那么我不知道如何像电子邮件客户端那样做同样的事情。目前python给出错误“服务器配置问题”
SMTPserver = 'smtp.xxxx.com
SMTPport = 587
sender = 'info@xxx.com'
destination = ['testgmailid@gmail.com']
USERNAME = "info@xxxx.com"
PASSWORD = "1234"
text_subtype = 'plain'
subject="Sent from Python"
import sys
import os
import re
from smtplib import SMTP
from email.MIMEText import MIMEText
try:
msg = MIMEText(content, text_subtype)
msg['Subject']= subject
msg['From'] = sender
conn = SMTP(SMTPserver,SMTPport)
conn.set_debuglevel(True)
conn.ehlo()
conn.starttls()
conn.login(USERNAME, PASSWORD)
try:
conn.sendmail(sender, destination, msg.as_string())
finally:
conn.close()
except Exception, exc:
sys.exit( "mail failed; %s" % str(exc) ) # give a error message