Reputation: 2642
Am using gmail smtp to send email messages and it works fine. The only problem is that I want receipients of the email to reply to a different email address. In other words I send them an email as from [email protected]
but when they click reply the message should be replied to [email protected]
or [email protected]
. How can I accomplish this please.
In my settings.py
I have:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
In my views.py
I have:
email = EmailMessage(
subject='Registration Successful',
body=msg,
from_email='My Name <[email protected]>',
to='[email protected]')
email.send()
This works but the recipient replies to [email protected]
. I want the recipient to reply to [email protected]
. Please What do I need to do to this code.
Upvotes: 1
Views: 1212
Reputation: 16796
Try adding a Reply-To
header to the email:
email = EmailMessage(
subject='Registration Successful',
body=msg,
from_email='My Name <[email protected]>',
to='[email protected]',
headers={'Reply-To': '[email protected]'})
email.send()
Upvotes: 5