Ethra8 / english-grows

Project 5 : E-commerce
0 stars 1 forks source link

As a **USER**, I want to be able to **receive an email confirmation after registering**, so that I can **verify that my account registration was successful** #5

Closed Ethra8 closed 5 hours ago

Ethra8 commented 1 month ago

As a USER, I want to be able to receive an email confirmation after registering, so that I can verify that my account registration was successful

Ethra8 commented 6 hours ago

Issue has been reopened, because although it did send a confirmtion email via the terminal, the function to actully send real emails was not completed at all. Will get to it soon.

Ethra8 commented 5 hours ago

Email is sent: Image

This code has been added to settings.py:

if DEBUG == True:
    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
    DEFAULT_FROM_EMAIL = 'englishgrows@example.com'
else:
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_USE_TLS = True
    EMAIL_PORT = 587
    EMAIL_HOST = 'smtp.gmail.com'
    EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
    EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
    DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL')

This way, when DEBUG is set to true during development fase, the console is used to receive sent emails, while being DEBUG set to false, the if statement will set the backend using smtp to send a real emal.