Using Google to Send Mail in Django
If you have a Gmail account (or a Google Apps account), you can use it to send mail on your behalf just like any other email client. Remember to use port 587 (not 465), and an “application-specific” password if you use 2-step verification.
EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = '[email protected]' EMAIL_HOST_PASSWORD = 'secret' EMAIL_PORT = 587 EMAIL_USE_TLS = True
The only thing interesting I’ve noticed here is that Google seems to disregard the “from” header and sends every email as you.
For example, attempting the following:
>>> from django.core.mail import send_mail >>> >>> send_mail('Test', 'Test message', '[email protected]', ['[email protected]'])
will send the email successfully to [email protected]
, but will come “from” [email protected]
.