Can anyone help me with to configure my django cookiecutter production setup to work with Gmail SMTP.
I have deployed my application using docker. Cookiecutter gives you to configure your app to anymail providers. I've chosen Mailgun however I didn't have an email address that has been verified by my domain provider. So, I couldn't register any user to my app because ( https://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html#configuring-the-stack) here it says you can't :)
I have tried to override the default email verification setting from "mandatory" to "none". However, it still threw 500. In below, I've added all-auth settings. I had to decide either to buy an email address or configure my app to work with Gmail Smtp or get rid of this email verification process.
settings/base.py
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_AUTHENTICATION_METHOD = "username"
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_EMAIL_REQUIRED = True
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_EMAIL_VERIFICATION = "none"
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
)
Any way to get rid of this 500 would be awesome.
You don't config email host and email from the sender. Try this
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
)
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = "your_email@gmail.com"
EMAIL_HOST_PASSWORD = "email_password"
DEFAULT_FROM_EMAIL = "email_of_sender@gmail.com" # same with EMAIL_HOST_USER
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
# https://docs.djangoproject.com/en/dev/ref/settings/#email-timeout
EMAIL_TIMEOUT = None