script to send email to receipient for undelivered message

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
nvvnravi
Normal user
Normal user
Posts: 90
Joined: 2013-06-04 16:53

script to send email to receipient for undelivered message

Post by nvvnravi » 2018-02-27 04:40

we have a situation where we need to inform the recipient when a message is not getting delivered because their mailbox is almost full .
Q) i know that in this case the sender receives an email from
mailer-daemon@127.0.0.1 <mailer-daemon@127.0.0.1
> which specifies the reason like the example below. i have tried to capture that event in OnDeliveryFailed but i see that this never gets executed. in the logs though i see the message
APPLICATION" 21336 "2018-02-26 21:27:33.362" "SMTPDeliverer - Message 191453: The message was not delivered.
Q)My other question is how to change the text inside the below message.

======================================================================================
Your message did not reach some or all of the intended recipients.

Sent: Mon, 26 Feb 2018 21:27:14 -0500 (EST)
Subject: Fwd:Fwd:Fwd:Fwd:Fwd:Fwd:An Important Message

The following recipient(s) could not be reached:

test3@mydomain.net
Error Type: SMTP
Error Description: Inbox is full
Additional information: The recipients inbox is full.
=====================================================================================

User avatar
mattg
Moderator
Moderator
Posts: 20632
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: script to send email to receipient for undelivered message

Post by mattg » 2018-02-27 06:17

First Question >> This is how i do it >> viewtopic.php?f=2&t=30313#p189528
On delivery failed is only triggered when a message that is accepted by your hMaislerver for local delivery, is later deleted by a rule or script


Second Question >> (only plain text, no HTML)
Admin GUI >> Settings >> Advanced >> Server Messages >> Send_Failed_Notification
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

nvvnravi
Normal user
Normal user
Posts: 90
Joined: 2013-06-04 16:53

Re: script to send email to receipient for undelivered message

Post by nvvnravi » 2018-02-27 17:39

Thank you for the response.

For Q1) Sorry forgot to mention , This email if for local delivery only. but still this script is not executed. any reason why this could be.
below is the trace log. i was expecting the script to be executed before the "Local delivery completed".
"APPLICATION" 21336 "2018-02-27 10:33:40.346" "SMTPDeliverer - Message 191456: Delivering message from test2@mydomain.net to test3@mydomain.net. File: C:\Program Files (x86)\hMailServer\Data\{BB2A2D25-85D9-42D3-99CC-AF1B6A30F7AB}.eml"
"DEBUG" 20932 "2018-02-27 10:33:40.336" "Ending session 35"
"DEBUG" 21336 "2018-02-27 10:33:40.357" "Executing event OnDeliveryStart"
"DEBUG" 21336 "2018-02-27 10:33:40.412" "Event completed"
"DEBUG" 21336 "2018-02-27 10:33:40.420" "Applying rules"
"DEBUG" 21336 "2018-02-27 10:33:40.427" "Executing event OnMessageDeliver"
"DEBUG" 21336 "2018-02-27 10:33:40.441" "Event completed"
"IMAPD" 20932 40 "2018-02-27 10:33:40.452" "127.0.0.1" "RECEIVED: A23 NOOP"
"DEBUG" 21336 "2018-02-27 10:33:40.454" "Performing local delivery"
"IMAPD" 20932 40 "2018-02-27 10:33:40.462" "127.0.0.1" "SENT: A23 OK NOOP completed"
"APPLICATION" 21336 "2018-02-27 10:33:40.471" "SMTPDeliverer - Message 191456: The message was not delivered to test3@mydomain.net. Delivery to this account was cancelled since the account inbox is full. Max size: 4 MB, Current size (including cancelled message): 5 MB"
"IMAPD" 21272 36 "2018-02-27 10:33:40.479" "127.0.0.1" "RECEIVED: A23 NOOP"
"DEBUG" 21336 "2018-02-27 10:33:40.487" "Local delivery completed"
"IMAPD" 21272 36 "2018-02-27 10:33:40.496" "127.0.0.1" "SENT: A23 OK NOOP completed"
"DEBUG" 21336 "2018-02-27 10:33:40.504" "SD::SubmitErrorLog_"
"DEBUG" 21336 "2018-02-27 10:33:40.539" "Saving message: {49085C2B-961C-4CDF-BCEF-10518E509816}.eml"
"DEBUG" 21336 "2018-02-27 10:33:40.544" "SD::~SubmitErrorLog_"
"IMAPD" 16532 36 "2018-02-27 10:33:40.548" "127.0.0.1" "RECEIVED: A24 APPEND "INBOX.Sent Mail" (\Seen) "27-Feb-2018 10:33:18 -0500" {1117726}"
"DEBUG" 21336 "2018-02-27 10:33:40.552" "Deleting message"
"IMAPD" 16532 36 "2018-02-27 10:33:40.559" "127.0.0.1" "SENT: + Ready for literal data"
"DEBUG" 21336 "2018-02-27 10:33:40.568" "Deleting message file."
"APPLICATION" 21336 "2018-02-27 10:33:40.586" "SMTPDeliverer - Message 191456: Message delivery thread completed."
"DEBUG" 20004 "2018-02-27 10:33:42.309" "Saving message: {99AC2ECF-704F-4591-B913-5137DCAC76C2}.eml"

For Q2- i would like to know how "%MACRO_RECIPIENTS%" is converted into the following . any documentation on these parameters.
test3@mydomain.net
Error Type: SMTP
Error Description: Inbox is full
Additional information: The recipients inbox is full.

User avatar
mattg
Moderator
Moderator
Posts: 20632
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: script to send email to receipient for undelivered message

Post by mattg » 2018-02-28 09:51

That message should have been bounced immediately it was undeliverable? Was it? I'm guessing it was based on the rejection notice that you got

%MACRO_RECIPIENTS% is just the (remaining) recipients of the message

I suspect that the error text is %MACRO_ORIGINAL_HEADER%

And yes the documentation can probably be improved here.
Feel free to submit suggested re-writes of the documentation, and I'll update it.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

nvvnravi
Normal user
Normal user
Posts: 90
Joined: 2013-06-04 16:53

Re: script to send email to receipient for undelivered message

Post by nvvnravi » 2018-02-28 18:40

Hi Mattg:

but the OnDeliveryFailed script is not executed in my case. that is the issue. if it had executed then i don't have issue.

User avatar
mattg
Moderator
Moderator
Posts: 20632
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: script to send email to receipient for undelivered message

Post by mattg » 2018-03-01 00:52

nvvnravi wrote:
2018-02-28 18:40
but the OnDeliveryFailed script is not executed in my case.
https://www.hmailserver.com/documentati ... veryfailed
Notice that the event is only executed if hMailServer has accepted a message for delivery. If hMailServer rejects a message, for instance during anti spam check, OnDeliveryFailed is not excuted.
In your case, the message is rejected due to recipient mailbox size.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Post Reply