Skip to content

When Smtp is failed for any reason, it should be able to print error #43

Description

@Aladdin-97

Describe the bug
Hello,
the send email signal blocks the process when there is any kind of issue at SMTP level.

To Reproduce
Steps to reproduce the behavior:
i have a model sample such as:

class Order(models.Model, EmailSignalMixin):
    id = models.AutoField(primary_key=True)
    book = models.ForeignKey(Book, on_delete=models.CASCADE, related_name="booking_book")
    user = models.ForeignKey(User, on_delete=models.PROTECT, related_name="booking_user")`

in my views.py
book function:

if request.method == "POST":
        
        print("TEST saving to db")
        obj = Order.objects.create(user=request.user, book=book.name)
        print("TEST book ok")
        messages.success(
            request,
            f"<p>Dear <b>{request.user},</b></p><p>You have successfully booked </p>Thank you",
            extra_tags='alert-success'  # Allows HTML in the message
        )
        print(" TEST RELOADING")
        return HttpResponseClientRedirect("/")

logs:

TEST saving to db
smtplib.AnyTypeOfException: (error logs)
[14/Jun/2023 21:11:46] "POST /book/1/1/1/ HTTP/1.1" 500 144313

in the admin site, it is saved as signal post_save.
I have set a fake SMTP in docker (papercut).
The signal works when smtp is available. if for some reason, there is an issue (any kind of)
it just block the process in the UI. The book order is saved correctly but the interface stuck in loading as it doesn't go to the step to reload the page (see logs)

Expected behavior
It Should print an error message such as message not sent for X reason.
or at least not hangs the process of the booking

Desktop (please complete the following information):

  • OS: Centos8
  • Browser Any Browser
  • Version latest

am i doing anything wrong ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions