Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Aladdin-97 opened this issue Jun 14, 2023 · 0 comments
Open

Comments

@Aladdin-97
Copy link

Aladdin-97 commented Jun 14, 2023

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant