Duplicate number of emails due to complex forwarding rules

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
askrahulsingh
New user
New user
Posts: 5
Joined: 2016-05-17 07:10
Contact:

Duplicate number of emails due to complex forwarding rules

Post by askrahulsingh » 2019-09-18 08:23

Hello guys!!

I am not expert in hMailserver so my question might look silly for you :)

I have a case where user2 emails forwarding set to user3, suppose user1 is sending an email to user2 and mark user3 in CC then user3 getting 2 number of copies.

Example:
1) User2-->Forwarding set to-->User3

2)User1-->Email-->To: User2, CC: User3

3) User3 receiving 2 copies of same email

Can you please help me setting a RULE in hMailServer so that only one copy of emails would be deliver (Unique email Delivery based on message ID)

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

Re: Duplicate number of emails due to complex forwarding rules

Post by mattg » 2019-09-18 09:16

But there ARE two emails
#1 to user2, and #2 to user3
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
katip
Senior user
Senior user
Posts: 686
Joined: 2006-12-22 07:58
Location: Istanbul

Re: Duplicate number of emails due to complex forwarding rules

Post by katip » 2019-09-18 11:36

askrahulsingh wrote:
2019-09-18 08:23
Can you please help me setting a RULE in hMailServer so that only one copy of emails would be deliver (Unique email Delivery based on message ID)
no. not with rules.
this was one of my favorite(!) problems ever.
you need to capture Message-IDs in a seperate DB table and do lookups prior to delivery.
Katip
--
HMS 5.7.0-B2428-LTS-64-bit, MySQL 5.7.24, SA 3.4.2, ClamAV 0.101.2 + SaneS

askrahulsingh
New user
New user
Posts: 5
Joined: 2016-05-17 07:10
Contact:

Re: Duplicate number of emails due to complex forwarding rules

Post by askrahulsingh » 2019-09-19 08:20

May I please ask you to help me setting up these changes? I have a file called "EventHandlers.vbs", do I need to add some more scripts into it.

How do I process the messages for uniqueness?

askrahulsingh
New user
New user
Posts: 5
Joined: 2016-05-17 07:10
Contact:

Re: Duplicate number of emails due to complex forwarding rules

Post by askrahulsingh » 2019-09-19 09:14

katip wrote:
2019-09-18 11:36
askrahulsingh wrote:
2019-09-18 08:23
Can you please help me setting a RULE in hMailServer so that only one copy of emails would be deliver (Unique email Delivery based on message ID)
no. not with rules.
this was one of my favorite(!) problems ever.
you need to capture Message-IDs in a seperate DB table and do lookups prior to delivery.
May I please ask you to help me setting up these changes? I have a file called "EventHandlers.vbs", do I need to add some more scripts into it.

How do I process the messages for uniqueness?

User avatar
katip
Senior user
Senior user
Posts: 686
Joined: 2006-12-22 07:58
Location: Istanbul

Re: Duplicate number of emails due to complex forwarding rules

Post by katip » 2019-09-19 12:05

1. you set up a table in a seperate DB (not HMS DB), simply with MessageID and account address columns.
2. in account rules you need to call a function by rule #1 for each arriving message (if MessageSize > 0 then call a function) which looks up MsgID + address pair, if found, it writes a header (such as X-HMS-Duplicate = YES). if not found it merely creates a new record with this pair.
3. next rule #2 checks this header, if it finds it moves the message to a trash public folder as it means this account already got a copy of this mail. otherwise delivery is finished.

i think you understand the logic. sorry but i can't offer my own script as it's very customized and not documented.
and yes, all should be written in EventHandlers.vbs file.
Katip
--
HMS 5.7.0-B2428-LTS-64-bit, MySQL 5.7.24, SA 3.4.2, ClamAV 0.101.2 + SaneS

askrahulsingh
New user
New user
Posts: 5
Joined: 2016-05-17 07:10
Contact:

Re: Duplicate number of emails due to complex forwarding rules

Post by askrahulsingh » 2019-09-23 09:01

katip wrote:
2019-09-19 12:05
1. you set up a table in a seperate DB (not HMS DB), simply with MessageID and account address columns.
2. in account rules you need to call a function by rule #1 for each arriving message (if MessageSize > 0 then call a function) which looks up MsgID + address pair, if found, it writes a header (such as X-HMS-Duplicate = YES). if not found it merely creates a new record with this pair.
3. next rule #2 checks this header, if it finds it moves the message to a trash public folder as it means this account already got a copy of this mail. otherwise delivery is finished.

i think you understand the logic. sorry but i can't offer my own script as it's very customized and not documented.
and yes, all should be written in EventHandlers.vbs file.
Thank you so much for your response, Yaah I understood the logic of handling the duplicate messages.

Let me work on it, will take time for me but I will do it hopefully :)

Post Reply