def run(self, nickname=None, content=None, image=None):
text = content + "<br>" + "<img src={image} />".format(image=image) \
if image is not None else content
msg = MIMEText(text, _subtype="html", _charset="utf-8")
msg["Subject"] = "????"
msg["From"] = nickname + "<" + MAIL_SENDER + ">"
msg["To"] = ",".join(MAIL_RECEIVER_LIST)
try:
server = smtplib.SMTP()
server.connect(MAIL_HOST)
server.starttls()
server.login(MAIL_SENDER, MAIL_PASSWORD)
server.sendmail(MAIL_SENDER, MAIL_RECEIVER_LIST, msg.as_string())
server.close()
except Exception as e:
LOG.error('send mail failed with error: %s' % str(e))
return False
return True
评论列表
文章目录