请问,使用python可以发送贺卡或明信片吗?
还是只能发送普通邮件?
自带的smtplib本身就支持发送HTML邮件def send_mail(self, recipients, subject, body):
msg = MIMEMultipart('alternative')
msg.set_charset("utf-8")
msg['Subject'] = subject
msg['From'] = self.__email_from
msg['To'] = ";".join(recipients)
body = MIMEText(body, 'html', "utf-8")
msg.attach(body)
try:
client = smtplib.SMTP(self.__smtp_server_host)
client.login(self.__smtp_user_name, self.__smtp_user_password)
client.sendmail(self.__email_from, recipients, msg.as_string())
return True
except Exception, e:
traceback.print_exc()
logging.error(e)
return False
邮件内容可以包含HTML的格式。所以是可以实现的。
关键是你能不能把你的邮件构造成你想要的
玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd18575.html
相关文章 Recommend