gpt4 book ai didi

python - 使用 EmailMultiAlternatives 向 django 发送电子邮件

转载 作者:行者123 更新时间:2023-11-28 20:44:49 31 4
gpt4 key购买 nike

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

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com