def send_mail(msg, config = None):
if not config:
config = g_config
session = smtplib.SMTP(config['HOST'], config['port'])
session.ehlo()
session.starttls()
session.ehlo()
session.login(config['username'], config['pwd'])
headers = ["from: " + config['FROM'], "subject: " + config['SUBJECT'], "to: " + config['TO'], "mime-version: 1.0", "content-type: text/html"]
headers = "\r\n".join(headers)
msg = msg + '\r\n\r\n from ' + hostname + ' \r\n\r\n at ' + cwd
session.sendmail(config['FROM'], config['TO'], headers + "\r\n\r\n" + msg)
评论列表
文章目录