Quick start¶
Gmail API setup¶
Create Google Developer Account
Create New project
Enable Gmail API
Submit Consent Screen
Create OAuth client ID inside Credentials
Type: Web application
Redirect URI:
http://localhost:8000/gmailer/verify
You can replace
localhost:8000
with your own custom domain in Redirect URI
Download client cecret file in to project root as
google_client_secret.json
You can now go to Consent Screen for verification if you needed (Otherwise, only 100 logins allowed).
Django setup¶
Install python package:
pip install django-google-mailer
Add name of the sender in settings.py (This step is optional):
GMAIL_USER = "Django Admin"
Add Google Auth redirection URL in settings.py:
GMAIL_REDIRECT = "http://localhost:8000/gmailer/verify"
Here, GMAIL_REDIRECT
must be set to same URL as in OAuth Credentials instead of the url given above.
Include the google mailer URLconf in your project urls.py like this:
path('gmailer/', include('gmailer.urls')),
Visit http://localhost:8000/gmailer/ to display mailer urls.