我正在尝试使用带有 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()
最佳答案
要显示 Name
而不是电子邮件的用户名部分,只需执行以下操作
from_email = "info@domain.com <info@domain.com>"
或
from_email = "Name <info@domain.com>"
关于python - 使用 EmailMultiAlternatives 向 django 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25350849/