Setup gmail for sending emails in django (Easy way)

In this article I will be teaching you how to setup your gmail account and use it for sending emails in django

1. Enable 2 factor authentication

2. Creating app password

  • Now you will be shown something like this:
  • Now as shown in the image above, click on the security option.
  • In security tab under Signing in to Google you will find something called App passwords, click on that
  • It would ask for verification, after completing that you will be shown the following:
  • Now click on the select app dropdown, click on other (custom name) and then give it a name.
  • And then click on the generate button and you will be shown a popup with a 16 character password.
  • Make sure you write this password somewhere because it will be displayed only once.
  • And that’s it here comes the final step.

3. Setting up the gmail setting in settings.py file (django)

EMAIL_BACKEND = ‘django.core.mail.backends.smtp.EmailBackend’
EMAIL_HOST = ‘smtp.gmail.com’
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = ‘your_account@gmail.com’
EMAIL_HOST_PASSWORD = ‘The app password that you have taken down’

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ashwin B

I love the internet, technology and building beautiful things