2

我正在尝试使用带有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()
4

1 回答 1

7

Name显示而不是电子邮件的用户名部分,只需执行

from_email = "info@domain.com <info@domain.com>"

或者

from_email = "Name <info@domain.com>"
于 2014-08-17T16:05:05.413 回答