Get status code of error message

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
cblaze22
Normal user
Normal user
Posts: 165
Joined: 2011-08-30 20:16

Get status code of error message

Post by cblaze22 » 2019-05-05 04:01

Is there a strongly typed way to get the status code of a bounced email from?

Code: Select all

   Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
I know I can parse the message below but thought there was an easier way. Also if I had to parse the string what is [nl]?
"Error Type: SMTP[nl] Remote server (35.173.65.153) issued an error.[nl] hMailServer sent: [nl] Remote server replied: 421 spr-ibgw-5001a.stratus.cloudmark.com cmsmtp SMTP server not available AUP#1330[nl]"

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

Re: Get status code of error message

Post by mattg » 2019-05-05 04:13

nl = New Line


OnDeliveryFailed is only for incoming messages that accepted by hMailserver

It fires for me ONLY when a global rule deletes a message
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

cblaze22
Normal user
Normal user
Posts: 165
Joined: 2011-08-30 20:16

Re: Get status code of error message

Post by cblaze22 » 2019-05-05 05:03

Sorry I am not following these comments
OnDeliveryFailed is only for incoming messages that accepted by hMailserver

It fires for me ONLY when a global rule deletes a message

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

Re: Get status code of error message

Post by mattg » 2019-05-05 09:08

OnDeliveryFailed (the sub you referenced) is only for mail being sent to your hmailserver, it is not for messages that get bounced by other servers.

I suspect that you are wanting to track messages that are bounced by other servers.
The ONLY way that you can do is by parsing the log files
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

cblaze22
Normal user
Normal user
Posts: 165
Joined: 2011-08-30 20:16

Re: Get status code of error message

Post by cblaze22 » 2019-05-05 15:35

Are you sure about this?

We received this message below in our logs from that method. That seems like a message from a delivery fail?

Code: Select all

"Error Type: SMTP[nl] Remote server (35.173.65.153) issued an error.[nl] hMailServer sent: [nl] Remote server replied: 421 spr-ibgw-5001a.stratus.cloudmark.com cmsmtp SMTP server not available AUP#1330[nl]"

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

Re: Get status code of error message

Post by mattg » 2019-05-06 02:05

How do you know that it came from that method?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

cblaze22
Normal user
Normal user
Posts: 165
Joined: 2011-08-30 20:16

Re: Get status code of error message

Post by cblaze22 » 2019-05-06 02:55

Cause I wrote it?????????

Code: Select all

   Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
EventLog.Write(sErrorMessage)
   End Sub

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

Re: Get status code of error message

Post by mattg » 2019-05-06 03:33

You are correct

I just forced the same message to fail, and it did log for me too. I obviously don't have many failures, I couldn't find one so far this month when I looked earlier.

Mine logged

Code: Select all

2019-05-06 11:28:47.371  OnDeliveryFailed:- test   matt@example.com   sdsfjkld@jhfjksfyjdsyjhg.com   Error Type: SMTP
   Error Description: No mail servers appear to exists for the recipient's address.
   Additional information: Please check that you have not misspelled the recipient's email address.
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