Suppose you decide to use gmail as your outgoing smtp server, you need to set the following values.
EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
#smtp is the default email backend.But,here I am setting this explicitly.
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'sajanjoseph@gmail.com'
EMAIL_HOST_PASSWORD = 'mysecretpass'
EMAIL_USE_TLS = True
Gmail uses TLS3 for outgoing smtp server for communication security.So,you need to set the EMAIL_USE_TLS to True.Otherwise,you will get an SMTPException.
The port used by gmail for TLS is 587.
In django,the django.core.mail module uses send_mail() method for sending emails.The third argument to this method is the email address of sender or more precisely this alias(it can be god@heaven.com).But,Gmail does not use alias,so you can even set it to None or empty string.It doesn't matter.The recepient will get an email from your gmail address.The same is true for EmailMessage class.
No comments:
Post a Comment