Search code examples
djangoemailsmtp-auth

Django send email where smtp auth is different then from_email


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= '[email protected]'
EMAIL_HOST_PASSWORD= 'password_for_something_at_gmail_com'

and to send an email I did

send_mail(subject=subject, message="test", from_email="[email protected]",
recipient_list=to, fail_silently=False)

this works but the received email does not show

from : [email protected] 

it shows

from: [email protected]

How do I make sure it shows [email protected].

NOTE: somedomain.com is connected with google apps and mydomain.com is alias with it and [email protected] is just an fwd email id.


Solution

  • Gmail doesn't allow you to change the From address when sending email through its servers.