From 4a3cfa4886953997f8a86f40b85593e80a111e59 Mon Sep 17 00:00:00 2001 From: lalanza808 Date: Sun, 5 Jan 2020 01:08:18 -0800 Subject: [PATCH] making app sendgrid compatible to circumvent ses --- .env.example | 3 +++ requirements.txt | 1 + xmrauctions/settings.py | 18 +++++++++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index b8ce122..e0a8957 100644 --- a/.env.example +++ b/.env.example @@ -18,3 +18,6 @@ DEBUG=true # If no DEBUG AWS_STORAGE_BUCKET_NAME=xxxxxxxxxxxxxx AWS_S3_CUSTOM_DOMAIN=xxxxxxxxxxxxxxx + +# Email +SENDGRID_API_KEY=xx diff --git a/requirements.txt b/requirements.txt index d0cea89..a159213 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ Django==2.2.8 boto3==1.10.45 Pillow==6.2.1 django-cors-headers==3.2.0 +django-sendgrid-v5==0.8.1 django-redis==4.11.0 django-registration==3.0.1 django-storages==1.8.0 diff --git a/xmrauctions/settings.py b/xmrauctions/settings.py index 2fb84c4..acea3a5 100644 --- a/xmrauctions/settings.py +++ b/xmrauctions/settings.py @@ -219,13 +219,17 @@ WALLET_PASS = os.environ.get('WALLET_PASS', '') # Email info -EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'django.core.mail.backends.console.EmailBackend') -EMAIL_FROM = 'noreply@xmrauctions.net' -EMAIL_HOST = os.environ.get('EMAIL_HOST', None) -EMAIL_PORT = os.environ.get('EMAIL_PORT', None) -EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', None) -EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', None) -EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', None) +DEFAULT_FROM_EMAIL = f'{SITE_NAME} ' +# EMAIL_HOST = os.environ.get('EMAIL_HOST', None) +# EMAIL_PORT = os.environ.get('EMAIL_PORT', None) +# EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', None) +# EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', None) +# EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', None) +SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY', False) +if SENDGRID_API_KEY: + EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend' +else: + EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'django.core.mail.backends.console.EmailBackend') # CORS