最新Django3.1大神之路视频!长达77小时、17G、233节 ,全方位无死角深入源码的专注教程!包含完整的模型层、数据迁移、 类视图、异步视图、日志、认证权限和开发工具等更多文字教程未包含的内容。免费章节pan.baidu.com/s/1dqGWNwmBnLxhM7DnXiePIQ 提取码:ko4y 。查看视频介绍点我


user_image
By  世外就是TaoYuan    On   2018年1月23日 17:27

```py #!/usr/bin/env python # -*- coding: utf-8 -*- # Created by TaoYuan on 2018/1/23 0023. # @Link : http://blog.csdn.net/lftaoyuan # Github : https://github.com/seeways import os from django.core.mail import send_mail, EmailMultiAlternatives os.environ['DJANGO_SETTINGS_MODULE'] = 'MyBlog.settings' if __name__ == '__main__': subject = "来自TaoYuan的测试邮件" from_email = "m18816740231@163.com" to = ["1876665310@qq.com"] text_content = "Github: https://github.com/seeways CSDN: http://blog.csdn.net/lftaoyuan" html_content = "<p>Github:<a href='https://github.com/seeways'>seeways</a></p><br><p>CSDN:<a " \ "href='http://blog.csdn.net/lftaoyuan'>TaoYuan</a></p> " # send_mail(主题, 内容, 发送者, 接收列表,其他默认参数) send_mail( subject, text_content, from_email, to, html_message=html_content ) # 优先发送html_content, html内容无效时,发送text # msg = EmailMultiAlternatives(subject, text_content, from_email, to) # msg.attach_alternative(html_content, "text/html") # msg.send() ```