【问题标题】:Email django from using EmailMultiAlternatives使用 EmailMultiAlternatives 向 django 发送电子邮件
【发布时间】: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


【解决方案1】:

要显示Name 而不是电子邮件的用户名部分,只需这样做

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-15
    • 2013-03-07
    • 2011-10-18
    • 2020-08-17
    • 1970-01-01
    • 2016-06-10
    • 2017-09-29
    • 1970-01-01
    相关资源
    最近更新 更多