【发布时间】:2014-10-10 15:08:58
【问题描述】:
我正在尝试使用带有 EmailMultiAlternatives 的 Django 发送邮件。它运作良好,但在“来自”中说“信息”
例如可以说我的名字吗?我该怎么做?
这是我的代码:
subject, from_email, to = 'Afiliations', 'info@domain.com', 'other@domain.com'
text_content = 'Afiliation is working.'
t = loader.get_template('emails/afiliados.html')
c = Context({ 'order': order_obj })
html_content = t.render(c)
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
【问题讨论】:
-
您想在电子邮件收件箱中显示自定义名称?
-
为什么不从您的域中更改名称?
-
我认为它占用了电子邮件的用户名部分。试试这个:
"<info@domain.com> info@domain.com" -
如果我为此更改域:myname@domain.com 那么“from”将是“myname”但不大写。我认为这不是正确的做法。
-
感谢@karthikr,这有效:“名称
”。如果你想回答我可以标记为正确。
标签: python django email html-email mailing