Global rule to catch all incoming mail

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
Hazark
New user
New user
Posts: 26
Joined: 2014-05-08 23:17

Global rule to catch all incoming mail

Post by Hazark » 2015-03-20 10:58

I need a copy of e-mails which originated from an external server. Anyone have an idea on that?

If this is not possible (within hmailserver), I need to catch all incoming mail to server and forward (or save a copy) to another address. I can manually filter it against my users addresses later.
Global rules and mirror function triggers from inbound AND outbound traffic so it's not usable for my scenerio.

If I hit the language barrier on my post above; here is a visualization

Code: Select all

Sender          | Receiver          | Do I need a copy of that
==============================================================
*@external.com  | *@dtroms.com      | YES
*@dtroms.com    | *@dtroms.com      | NO
*@dtroms.com    | *@external.com    | NO

dtroms = domain that resides on my server
Thanks.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8124
Joined: 2011-09-08 17:48

Re: Global rule to catch all incoming mail

Post by jimimaseye » 2015-03-20 11:28

Hazark wrote:Global rules and mirror function triggers from inbound AND outbound traffic so it's not usable for my scenerio.
Not true.

GLOBAL RULE

if
FROM ....not contain.... DTROMS.COM
then
forward....

Make sure you code the rule for LOOPS
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Hazark
New user
New user
Posts: 26
Joined: 2014-05-08 23:17

Re: Global rule to catch all incoming mail

Post by Hazark » 2015-03-20 11:45

The problem is dtroms.com actually a placeholder that means "domain that resides on my server" and there are many of them.
If I choose that way, I must list every domain I have on the rule definition and update it when a new domain added/removed on the server.

Doable, maybe I can automate the rule definition update process with mysql triggers. If anyone thinks another way to do this, please post it; thanks.

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

Re: Global rule to catch all incoming mail

Post by SorenR » 2015-03-20 14:19

Hazark wrote:I need a copy of e-mails which originated from an external server. Anyone have an idea on that?

If this is not possible (within hmailserver), I need to catch all incoming mail to server and forward (or save a copy) to another address. I can manually filter it against my users addresses later.
Global rules and mirror function triggers from inbound AND outbound traffic so it's not usable for my scenerio.

If I hit the language barrier on my post above; here is a visualization

Code: Select all

Sender          | Receiver          | Do I need a copy of that
==============================================================
*@external.com  | *@dtroms.com      | YES
*@dtroms.com    | *@dtroms.com      | NO
*@dtroms.com    | *@external.com    | NO

dtroms = domain that resides on my server
Thanks.
How is your VBScript ?

Following assume authentication is active for local accounts..

Code: Select all

EventHandlers.vbs


   Sub OnAcceptMessage(oClient, oMessage)
      If (oClient.Username = "") Then
         oMessage.HeaderValue("X-dtroms-True") = "YES"
         oMessage.Save
      End If
   End Sub


Global Rule

   Criteria (AND):
      If Custom header field "X-hMailServer-LoopCount" < 1
      If Custom header field "X-dtroms-True" = "YES"

   Action:
      Forward email "dtroms@acme.inc"
SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

Hazark
New user
New user
Posts: 26
Joined: 2014-05-08 23:17

Re: Global rule to catch all incoming mail

Post by Hazark » 2015-03-20 14:50

SorenR wrote: Following assume authentication is active for local accounts..

..code..
Authentication is enabled and your solution seems working well (based on my 2 minute test). Will try for longer periods.

Thanks and have a nice day.

Post Reply