1

I have set up the django smtp backend to use gmail smtp. and it sends email perfectly, But there is one problem.

The authentication I use for gmail smtp is different then the from_email, still when I receive an email I see the from email id as the smtp auth email.

example: my settings are as follow:

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER= 'something@somedomain.com'
EMAIL_HOST_PASSWORD= 'password_for_something_at_gmail_com'

and to send an email I did

send_mail(subject=subject, message="test", from_email="other@mydomain.com",
recipient_list=to, fail_silently=False)

this works but the received email does not show

from : other@mydomain.com 

it shows

from: something@somedomain.com

How do I make sure it shows other@mydomain.com.

NOTE: somedomain.com is connected with google apps and mydomain.com is alias with it and other@mydomain.com is just an fwd email id.

4

2 回答 2

1

Gmail不允许您在 通过其服务器发送电子邮件时 更改发件人地址。

于 2013-10-24T16:50:44.647 回答
0

您可以使用以下电子邮件发送代码覆盖 From 标头。

从 django.core.mail 导入 EmailMessage

EmailMessage(主题, 消息, "<"+str(from_email)+">", 收件人列表)

注意:实际上它会从您在 settings.py 文件中配置的电子邮件 ID 发送电子邮件,但 From 标头将显示 from_email 地址

于 2013-10-24T17:41:41.437 回答