switching mail services to mailgun

pull/3/head
lalanza808 5 years ago
parent e1a105ae3a
commit cf81b7f409

@ -1,8 +1,8 @@
Django==2.2.8
boto3==1.10.45
Pillow==6.2.1
django-anymail[mailgun]==7.0.0
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

@ -42,7 +42,8 @@ INSTALLED_APPS = [
'sales.apps.SalesConfig',
'core.apps.CoreConfig',
'huey.contrib.djhuey',
'corsheaders'
'corsheaders',
'anymail'
]
MIDDLEWARE = [
@ -220,15 +221,18 @@ WALLET_PASS = os.environ.get('WALLET_PASS', '')
# Email info
DEFAULT_FROM_EMAIL = f'{SITE_NAME} <noreply@xmrauctions.com>'
# 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'
EMAIL_DOMAIN = os.environ.get('EMAIL_DOMAIN', 'localhost')
EMAIL_FROM = os.environ.get('EMAIL_FROM', 'noreply')
DEFAULT_FROM_EMAIL = f'{SITE_NAME} <{EMAIL_FROM}@{EMAIL_DOMAIN}>'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
ANYMAIL = {
'MAILGUN_API_KEY': os.environ.get('MAILGUN_API_KEY', None),
"MAILGUN_SENDER_DOMAIN": os.environ.get('MAILGUN_SENDER_DOMAIN', EMAIL_DOMAIN),
}
if ANYMAIL['MAILGUN_API_KEY']:
print('emailgun')
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
else:
EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'django.core.mail.backends.console.EmailBackend')