Why does a Notification send two mails instead of one?

only one recipient configured
image
and configured to send on save
image
Why are two mails send to raised_by?

can you elaborate more?

If you set “Save” in Send Alert on, then if you save the doc multiple times then multiple time mail will be sent.

That of course makes perfect sense, but when I press “Safe” exactly once, two mails appear in mail queue and are sent when the scheduler iterates. They have the exact same recipient, sender and content, only their message id differs.

I found Notification (erpnext.com) in the docs, which uses a custom field and then uses that as a condition to suppress multiple mails.

Since both mails are generated at the very same time, I would suspect a race condition to be quite likely. Besides, that should not be the way to do it. Much rather one would like to know what exactly happens after “Save” and how the mail function is double triggered.

In frappe/frappe/email/doctype/notification/notification.py at 1b8e9c3502b702178f777cf2e5c253ccec573e2e · frappe/frappe · GitHub it looks as if an email is sent exactly once. I wonder where the double trigger event happens

2 Likes

Although not quite comprehensible to me, the order of conditions caused double or even more mails per save:

doc.issue_type!="Please call back" and doc.custom_email_sent!=1

Whereas this one works as expected:

doc.custom_email_sent!=1 and doc.issue_type!="Please call back"

Is my understanding of boolean logic flawed maybe? Anyway, it’s working now, on to the next things.