当前位置:首页 > 热点

Python 发送带有附件的邮件

Python 发送带有附件的发送附件邮件

条件使用from django.core.mail import EmailMessage引入EmailMessage类

示例代码

Python 发送带有附件的邮件

from django.core.mail importEmailMessage msg =EmailMessage(Subject of the Email,Body of the email,from@email.com,[to@email.com]) msg.content_subtype ="html" msg.attach_file(pdfs/Instructions.pdf) msg.send()

原理:

Python 发送带有附件的邮件

普通的send_mail()方法是EmailMessage类的一种简单的封装,站群服务器实现简单的有的邮发送邮件功能,但是发送附件如果要实现复杂的云南idc服务商功能,还得使用EmailMessage这个类,有的邮具体示例如上。发送附件

Python 发送带有附件的邮件

有的香港云服务器

分享到:

滇ICP备2023006006号-16