diff options
author | Matthew Lemon <y@yulqen.org> | 2024-12-08 17:37:55 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-12-08 17:37:55 +0000 |
commit | f8095c75f880a099fb8f08e05a359755458ef79a (patch) | |
tree | 1a8bac72e594bba899385e5bf1d283207730aa0e | |
parent | bc557f9ea2ec520533d0e697dbab8ae1539195c4 (diff) |
Uses Mailgun for production and local settings
- credentials are in the .env file
- uses the mailgun http API to send verification messages
-rw-r--r-- | alphabetlearning/payments/views.py | 13 | ||||
-rw-r--r-- | config/settings/base.py | 3 | ||||
-rw-r--r-- | config/settings/production.py | 5 |
3 files changed, 14 insertions, 7 deletions
diff --git a/alphabetlearning/payments/views.py b/alphabetlearning/payments/views.py index 4a65b48..5d8449d 100644 --- a/alphabetlearning/payments/views.py +++ b/alphabetlearning/payments/views.py @@ -89,15 +89,16 @@ def send_mailgun_verification( verification_url: str = None, warn=False, ): + breakpoint() if warn: warning_message = """ You are already subscribed to our list - no further action is required. """ requests.post( - "https://api.mailgun.net/v3/sandbox98fd3a1c6501446aa57a9c8b76e56e15.mailgun.org/messages", - auth=("api", "7535a010b822cd503dc5a11670a64194-f55d7446-76d3865a"), + f"{settings.MAILGUN_API_URL}/{settings.MAILGUN_SENDER_DOMAIN}/messages", + auth=("api", settings.MAILGUN_API_KEY), data={ - "from": "Excited User <mailgun@sandbox98fd3a1c6501446aa57a9c8b76e56e15.mailgun.org>", + "from": f"No reply - Alphabet Learning <noreply@{settings.MAILGUN_SENDER_DOMAIN}>", "to": [ email, ], @@ -112,10 +113,10 @@ def send_mailgun_verification( If you didn't request this, please ignore this email. """ requests.post( - "https://api.mailgun.net/v3/sandbox98fd3a1c6501446aa57a9c8b76e56e15.mailgun.org/messages", - auth=("api", "7535a010b822cd503dc5a11670a64194-f55d7446-76d3865a"), + f"{settings.MAILGUN_API_URL}/{settings.MAILGUN_SENDER_DOMAIN}/messages", + auth=("api", settings.MAILGUN_API_KEY), data={ - "from": "Excited User <mailgun@sandbox98fd3a1c6501446aa57a9c8b76e56e15.mailgun.org>", + "from": f"No reply - Alphabet Learning <noreply@{settings.MAILGUN_SENDER_DOMAIN}>", "to": [ email, ], diff --git a/config/settings/base.py b/config/settings/base.py index 28e40ed..9c6183c 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -356,3 +356,6 @@ AWS_S3_ENDPOINT_URL = env("SPACES_ENDPOINT_URL") # Your stuff... # ------------------------------------------------------------------------------ +MAILGUN_API_KEY = env("MAILGUN_API_KEY") +MAILGUN_SENDER_DOMAIN = env("MAILGUN_SENDER_DOMAIN") +MAILGUN_API_URL = env("MAILGUN_API_URL", default="https://api.eu.mailgun.net/v3") diff --git a/config/settings/production.py b/config/settings/production.py index f8e48ac..cfd7d78 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -226,4 +226,7 @@ LOGGING = { # Your stuff... -# ------------------------------------------------------------------------------ +# My manual Mailgun stuff +MAILGUN_API_KEY = env("MAILGUN_API_KEY") +MAILGUN_SENDER_DOMAIN = env("MAILGUN_DOMAIN") +MAILGUN_API_URL = env("MAILGUN_API_URL", default="https://api.eu.mailgun.net/v3") |