背景 :-
我的电子邮件后端是这样的:
EMAIL_HOST ='smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'feedback@example.com'
EMAIL_HOST_PASSWORD = 'XXX'
EMAIL_USE_TLS = True
问题:-
我正在使用 EmailMultiAlternatives 发送 html 邮件。现在我想定义 auth_user 和 auth_password 以便我可以更改“来自”。基本上我想超越 EMAIL_HOST_USER,但希望 from_email 冗长,即“支持团队”。怎么做到呢?
subject, from_email, to = "hello", 'Support Team','to_user@gmail.com'
text = "hello"
html = "<strong>hello</strong>"
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send(fail_silently=False,auth_user = 'support@example.me',auth_password = 'XXX')