Use mail_admins instead of send_mail.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4254baf09d
commit
ca8987ba3b
|
@ -1,7 +1,6 @@
|
|||
"""Loaded with the AppConfig.ready() method."""
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.mail import send_mail
|
||||
from django.core.mail import mail_admins
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.utils import timezone
|
||||
|
@ -15,11 +14,9 @@ from . import models
|
|||
def check_total_amount(sender: models.Payment, instance: models.Payment, **kwargs: dict) -> None: # noqa: ARG001
|
||||
"""Check that we receive Payments with the correct amount."""
|
||||
if instance.amount != instance.order.total_with_vat:
|
||||
send_mail(
|
||||
mail_admins(
|
||||
"Payment received: wrong amount",
|
||||
f"Please check payment ID {instance.pk}",
|
||||
settings.DEFAULT_FROM_EMAIL,
|
||||
settings.ADMINS,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import stripe
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.mail import send_mail
|
||||
from django.core.mail import mail_admins
|
||||
from django.db import transaction
|
||||
from django.http import HttpRequest
|
||||
from django.http import HttpResponse
|
||||
|
@ -80,7 +80,7 @@ def order_pay(request: HttpRequest, order_id: int) -> HttpResponse:
|
|||
cancel_url=base_domain + "/cancel",
|
||||
)
|
||||
except Exception as e:
|
||||
send_mail("Error in checkout", str(e), settings.DEFAULT_FROM_EMAIL, settings.ADMINS)
|
||||
mail_admins("Error in checkout", str(e))
|
||||
raise
|
||||
|
||||
# TODO: Redirect with status=303
|
||||
|
|
|
@ -127,6 +127,7 @@ EMAIL_BACKEND = env.str(
|
|||
default="django.core.mail.backends.console.EmailBackend",
|
||||
)
|
||||
DEFAULT_FROM_EMAIL = env.str("DEFAULT_FROM_EMAIL", default="")
|
||||
SERVER_EMAIL = env.str("SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
|
||||
# Parse email URLs, e.g. "smtp://"
|
||||
email = env.dj_email_url("EMAIL_URL", default="smtp://")
|
||||
EMAIL_HOST = email["EMAIL_HOST"]
|
||||
|
|
Loading…
Reference in a new issue