如何使用django send_mail显示名称而不是电子邮件地址? [英] How to display a name instead of email address with django send_mail?

查看:261
本文介绍了如何使用django send_mail显示名称而不是电子邮件地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户收到从django send_mail()发送的电子邮件时,我想要显示一个名称而不是电子邮件地址。

I want a name to appear instead of an email address when the user receives an email that is sent from django send_mail().

例如:

当使用下面的代码发送电子邮件时,收到该邮件的人会看到到@ ex。 com 在他的收件箱。我想要显示一个名字。

When an email is sent with the below code the person who receives it sees to@ex.com in his inbox. I would like a name to be displayed.

send_mail('subject', 'content', from@ex.com, ['to@ex.com'], fail_silently=False)

就像公司向用户发送电子邮件一样,我们看不到电子邮件地址我们看到公司名称。

Just like when companies send their emails to users, we dont see an email address instead we see the company name.

推荐答案

尝试使用显示名称

send_mail('subject', 'content', 'Name <from@ex.com>', ['to@ex.com'], fail_silently=False)

这篇关于如何使用django send_mail显示名称而不是电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆