onerrormessage : modifying "Unknown user" in recipient list

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
nis
New user
New user
Posts: 18
Joined: 2010-05-19 10:00

onerrormessage : modifying "Unknown user" in recipient list

Post by nis » 2020-04-16 21:37

hello,

in the documentation, it is stated the following events order :
OnClientConnect (oClient)
spam tests >> DNSBlackilists, HELOhost, MXRecords, SPF
OnSMTPData (oClient, oMessage)
spam tests >> SURBL, DKIM, Greylisting, integrated SpamAssasin
OnAcceptMessage (oClient, oMessage)

that means that OnacceptMessage is fired AFTER the recipient list is received

in onaccepmessage, this is to late, the invalid recipient is removed from the oMessage.recipients object

What I want to do is to trap the even when I receive an invalid recipient and I want to correct is

for exemple, if I receive an email xxx@miccrosoft.com, since this is not a local domain, onaccepmessage get the bad email and I was able to replace it by @microsoft.com

but if this is a local domain, let say my domain is @mydomain.com and I send a mail to xxx@mydomain.com, this is too late. the erreur "unknow user" has been generated and the user removed.

Do you see any solution to manage this case ?

many thanks

palinka
Senior user
Senior user
Posts: 1968
Joined: 2017-09-12 17:57

Re: onerrormessage : modifying "Unknown user" in recipient list

Post by palinka » 2020-04-16 21:49

Incorrect domain would never get to your server because it could not be resolved to your IP by the sending server. Only domains that have valid MX records can be resolved to your server.

nis
New user
New user
Posts: 18
Joined: 2010-05-19 10:00

Re: onerrormessage : modifying "Unknown user" in recipient list

Post by nis » 2020-04-18 12:47

thanks for the answer but this is not exactly my problem. i what perhaps not clear.

I give an exemple :

I have my smtp serveur handling mails for the domain mydomain.com

I have a client that send to this serveur a mail to "bademail@mydomain,goodemail@domain.com"

in acceptmessage events , when I check oMessage.Recipients list, "bademail@mydomain" is not listed any more,
this is normal since this email has been refused when the smtp received "RECEIVED: RCPT TO:<bademail@mydomain>" command.

so, what I want, is to detect in some kind of procedure in EventHandlers.vbs that I received a request to send a mail to "bademail@mydomain"

many thanks in advance

User avatar
SorenR
Senior user
Senior user
Posts: 3624
Joined: 2006-08-21 15:38
Location: Denmark

Re: onerrormessage : modifying "Unknown user" in recipient list

Post by SorenR » 2020-04-18 13:14

nis wrote:
2020-04-18 12:47
thanks for the answer but this is not exactly my problem. i what perhaps not clear.

I give an exemple :

I have my smtp serveur handling mails for the domain mydomain.com

I have a client that send to this serveur a mail to "bademail@mydomain,goodemail@domain.com"

in acceptmessage events , when I check oMessage.Recipients list, "bademail@mydomain" is not listed any more,
this is normal since this email has been refused when the smtp received "RECEIVED: RCPT TO:<bademail@mydomain>" command.

so, what I want, is to detect in some kind of procedure in EventHandlers.vbs that I received a request to send a mail to "bademail@mydomain"

many thanks in advance
What if you compare oMessage.To and oMessage.Cc with the oMessage.Recipients list? It will never be 100% accurate since there is no oMessage.Bcc but assuming your clients do not spoof emails you may find them this way... Just an idea ;-)

The alternative is to "tail -f" the logfile...

https://www.hmailserver.com/forum/viewt ... 20&t=34119
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

nis
New user
New user
Posts: 18
Joined: 2010-05-19 10:00

Re: onerrormessage : modifying "Unknown user" in recipient list

Post by nis » 2020-04-21 23:03

thanks for the help
I will try this

Post Reply