Deleting An Email From Within OnAcceptMessage

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Deleting An Email From Within OnAcceptMessage

Post by Hotlanta » 2007-01-31 13:39

I'm trying to figure out the best way to delete an email from within OnAcceptMessage. I don't want to return the email. I want it to go away.

I looked around for example code, and didn't see anyone doing this. I do see the Messages.deletebydbid method, but I'm not sure of the best way to use it from within OnAcceptMessage. We have access to the oMessage and oClient objects, but we don't appear to have internal access to the Messages object. Do we have to authenticate to the server from within OnAcceptMessage like an external script would have to do?

An example of how to do this would be helpful.

Regards,

John

Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Post by Hotlanta » 2007-02-15 12:39

Nobody answered with a solution to this, but I found a way to do this pretty easily. I simply created a global rule that deletes the mail based on text in the header. Since OnAcceptMessage processes before the global rules (or the account rules for that matter), this works well.

For those of you curious why this is useful, I've found that zen.spamhaus.org is an excellent black list without a single false positive that I've detected as of yet. Consequently, I trust that anything that it flags can be safely tossed. Yes, I could allow hMS to return the mail, but then it would also return mail for the other spam checks as well. The MX, SPF, and HELO checks are still suspect, and rather than deleting or returning email that isn't confirmed spam, I'd rather mark them as spam and send them to the end user. By creating the global rule to delete emails that failed spamhaus, it cuts down on 85% of my spam while still allowing for false positives using other methods.

So why delete the mail instead of returning it? Well as a member of many Yahoo Groups, I've noticed that sometimes the Yahoo servers can get blacklisted. If I bounce their mail back at them, then they inactivate my email address (even though it's their server that's been blacklisted). By simply deleting the mail rather than returning it, I prevent this from happening. I would think this could be a problem with any subscription service.

tonda
Normal user
Normal user
Posts: 93
Joined: 2006-10-20 14:13
Location: CZ

Post by tonda » 2007-02-18 13:15

Did you check documentation for example here: http://www.hmailserver.com/documentatio ... eptmessage

You can reject message by setting Result value. I think this is exactly what you need.

zen.spamhaus.org is perfect black list but I have found some false positives coming from PBL list...

Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Post by Hotlanta » 2007-02-18 20:06

tonda wrote: Did you check documentation for example here: http://www.hmailserver.com/documentatio ... eptmessage

You can reject message by setting Result value. I think this is exactly what you need.
Yes, I saw that, but it's not what I was looking for. I don't want reject the email since that notifies the sending server that the mail was rejected. Although we do have the ability to reject with a custom rejection message or none, it still sends the rejection 542 code to the sending server.

I'm looking for a way to just delete the mail without notifying the server. It's not a big deal at this point since I figured out a work around that's getting it done.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2007-02-18 20:11

Hotlanta, the only way to do it is the way you did it..

Post Reply