How to Add Gmail Email Settings to Django


In this article, we show how to add gmail email settings to Django.

So, in order to add an email to Django, it is best done by adding it to the file. File

So we go to the file our project directory.

In this file, we add the following lines of code.

So this is all that is needed to send up a gmail account in Django.

So the EMAIL_BACKEND variable is standard and doesn't change from email service provider.

The EMAIL_HOST is "".

Usually, the EMAIL_HOST is equal to", but this still can vary, so when using other email service providers, check their settings.

The EMAIL_HOST_USER is equal to the specific email account from which the email will be sent. In this example, we just simply put the email as "". You would put the email account you want to use as the value.

The EMAIL_HOST_PASSWORD is the password of the email account you are using. So it would be the password for "" in this example.

Gmail uses port 587, so we set EMAIL_PORT equal to 587.

Gmail uses TLS, so we set EMAIL_USE_TLS to True.

DEFAULT_FROM_EMAIL is the email that you want to send from. We are sending from "". In some cases, some email service providers will allow you to specify another email as the from email. Gmail may not allow it, but some others do. We, however, just keep the from email to "".

And this is all that is required to set up a gmail SMTP account in Django.

Related Resources

How to Randomly Select From or Shuffle a List in Python

HTML Comment Box is loading comments...