Skip to content

add google mail to project #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[email protected]
EMAIL_HOST_PASSWORD=abcd efgh ijkl mnop
# app passwords are 16 characters like above. but you should get it from google and put yours!
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ db.sqlite3
media

# Virtual environment
venv/
.venv
.env

# Screencast
Lithium_Demo_2025.mp4
15 changes: 13 additions & 2 deletions django_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import os
from dotenv import load_dotenv
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
load_dotenv(os.path.join(BASE_DIR, '.env'))


# Quick-start development settings - unsuitable for production
Expand Down Expand Up @@ -165,8 +168,16 @@
CRISPY_TEMPLATE_PACK = "bootstrap5"

# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD")
# You should define EMAIL_HOST_USER and EMAIL_HOST_PASSWORD
# in your .env file. If one of them is not found, django uses default console.EmailBackend
if not EMAIL_HOST_USER or not EMAIL_HOST_PASSWORD:
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
DEFAULT_FROM_EMAIL = "root@localhost"

Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
asgiref==3.8.1
certifi==2022.12.7
cffi==1.15.1
cffi==1.17.1
charset-normalizer==3.0.1
crispy-bootstrap5==2024.10
cryptography==39.0.1
Expand All @@ -16,11 +16,13 @@ packaging==23.1
psycopg==3.2.3
psycopg-binary==3.2.3
pycparser==2.21
PyJWT==2.6.0
PyJWT==2.7.0
python-dotenv==1.1.1
python3-openid==3.2.0
requests==2.28.2
requests-oauthlib==1.3.1
sqlparse==0.4.3
typing_extensions==4.9.0
tzdata==2025.2
urllib3==1.26.14
whitenoise==6.7.0