美文网首页
django邮件发送

django邮件发送

作者: nice生活 | 来源:发表于2018-10-05 13:37 被阅读0次

    配置setting

    #smtp服务器
    EMAIL_HOST = "xxx"
    EMAIL_PORT = 25
    # 登录凭证SMTP服务器/填写自己邮箱
    EMAIL_HOST_USER ="xxx"
    EMAIL_HOST_PASSWORD = "19970123qaz"
    #发送者邮箱最好与EMAIL_HOST_USER一致
    EMAIL_FROM = "dengyaopersonal@aliyun.com"
    #设置为True则为安全连接
    EMAIL_USE_TSL = False
    

    编写发送邮件函数

    from django.core.mail import send_mail
    from xxx.settings import EMAIL_FROM
    
    
    def send_email(email):
        title = "xxx"
        body = "xxx"
        send_status=send_mail(title,body,EMAIL_FROM,[email])
        if send_status==1:
               return 'ok'
        return "error"
    

    相关文章

      网友评论

          本文标题:django邮件发送

          本文链接:https://www.haomeiwen.com/subject/recboftx.html