no auto-reply in distributionlists

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
chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

no auto-reply in distributionlists

Post by chris0602 » 2016-07-15 16:41

Hi all,

is it possible not to send an auto-reply if a mail comes through a distributionlist?
If auto-reply in hmail is set and a mail comes directly to the mailbox, the auto-reply should be sent.
But if a mail goes to a distributionlist and a member has set auto-reply, no reply should be sent.

Is there a setting in hmail or do you have a tip how to do it with a script?

Thanks

Chris

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

Re: no auto-reply in distributionlists

Post by mattg » 2016-07-15 18:12

chris0602 wrote:But if a mail goes to a distributionlist and a member has set auto-reply, no reply should be sent.
Why?

Not easy to catch with a script, because hmailserver doesn't realise that the message was sent to a distribution list initially
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

Re: no auto-reply in distributionlists

Post by chris0602 » 2016-07-18 10:34

Why?
For example:
A sender sends a mail to info@xxx.xxx and member a@xxx.xxx have auto reply activated.
The sender gets the auto-reply with from address a@xxx.xxx, but we don't want, that the sender is seeing the mailaddress of the members.
And it's no need to see that a member of the distributionlist is unavailable because there are always other members of the list available which take care of the incoming mails.

Is it possible to check with the api if a auto-reply is activated, then to check if the to address is not own address and then suppress the auto-reply?
Can you give me a hint where to look in the reference?
Do you see any problems with that procedure?

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

Re: no auto-reply in distributionlists

Post by mattg » 2016-07-18 15:06

chris0602 wrote:Is it possible to check with the api if a auto-reply is activated
At account level https://www.hmailserver.com/documentati ... ct_account, look for vacation message at the bottom of that page

You would need to check every account that was part of the group individually to see if the message was addresses to the distribution list, and if so stop the autoreply....


I think an easier way...

Create an account say sales@acme.org
Set this account to forward to sales.list@acme.org
Do not keep a copy

Where sales.list is your distribution list

When Autoreplies are made they are not sent back to the original sender

It does slow the process down for 1 minute (as the forward happens exactly after a minute), but if you can live with that this could work for you
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: no auto-reply in distributionlists

Post by percepts » 2016-07-18 16:48

I use a script which was intended to keep members email address private. As an unintended byproduct, it stops any auto replies from any accounts in the distribution list when a mail is sent to/from the list.

just put it in onAcceptMessage and edit to your distlist email address (that's if you are happy with the fact it makes all members hidden to other members otherwise you need your own code to do what you want).

Code: Select all

 ' Distribution List handling
 if (oMessage.To = "mylist@mydomain.com") Then 
  oMessage.From = "mylist@mydomain.com"
  oMessage.FromAddress = "no-reply@mydomain.com"
  Dim oHeader
  For oHeader = 0 to oMessage.Headers.Count-1
   If (oMessage.Headers(oHeader).Name = "Reply-To") Then
    oMessage.Headers(oHeader).Value = "mylist@mydomain.com"
   End If 
   If (oMessage.Headers(oHeader).Name = "Return-Path") Then
    oMessage.Headers(oHeader).Value = "no-reply@mydomain.com"
   End If 
  Next
  oMessage.Save
 End If


chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

Re: no auto-reply in distributionlists

Post by chris0602 » 2016-07-19 16:19

mattg wrote:You would need to check every account that was part of the group individually to see if the message was addresses to the distribution list, and if so stop the autoreply....
That sounds good, but how can I stop the autoreply?
Simply deactivate it in the account object on onAcceptMessage event?
But how can I reactivate it after the message is received?
percepts wrote:I use a script which was intended to keep members email address private. As an unintended byproduct, it stops any auto replies from any accounts in the distribution list when a mail is sent to/from the list.
If I understand your script right, you change the from-address. So the auto-reply would sent to no-reply@mydomain.com. Right?
So with that script I would loose the address of the sender and would not be able to answer to the mail.

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

Re: no auto-reply in distributionlists

Post by jimimaseye » 2016-07-19 22:03

chris0602 wrote:
mattg wrote:You would need to check every account that was part of the group individually to see if the message was addresses to the distribution list, and if so stop the autoreply....
That sounds good, but how can I stop the autoreply?
Simply deactivate it in the account object on onAcceptMessage event?
But how can I reactivate it after the message is received?
Heres an idea off top of my head:

SCRIPT:
when receiving an email at account level, check to see if the account address it comes has auto-reply enabled. IF YES:....

.... then check it belongs a distribution list (stick all distribution lists that the address belongs to in an array (eg, the address is found to belong in DIST1@ and DIST2...).

Then check to see if those distribution lists in the array is addresses in the email recipients list. If any of them are, then the conclusion is that this email came in via distribution list. THEN... modify that email and append a keyword to the subject (eg, "DISTNOREPLY").

Then, you have a global rule:

where FROM is local (ie, its not from external address) and
SUBJECT contains "DISTNOREPLY" (ie, its from one of the matching emails above come in by distribution list) and
has a AUTO-SUBMITTED header (ie, it came from an auto-reply message)

then delete message. This will prevent those out of office messages getting delivered. (It wont affect the original inbound message because that will not have the "DISTNOREPLY" marker).


If an email came in directly to the account (not by distribution list address) then it will be 'auto-replied' as normal because the "DISTNOREPLY" keyword will not be present.

Just a script and a rule. (Avoids guess work about who and when return-paths get used, or fromaddresses or who the sender was. It just gets on with deleting the outgoing auto-reply to whoever it was destined to).

Just a thought.
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

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: no auto-reply in distributionlists

Post by percepts » 2016-07-19 22:16

chris0602 wrote:
mattg wrote:You would need to check every account that was part of the group individually to see if the message was addresses to the distribution list, and if so stop the autoreply....
That sounds good, but how can I stop the autoreply?
Simply deactivate it in the account object on onAcceptMessage event?
But how can I reactivate it after the message is received?
percepts wrote:I use a script which was intended to keep members email address private. As an unintended byproduct, it stops any auto replies from any accounts in the distribution list when a mail is sent to/from the list.
If I understand your script right, you change the from-address. So the auto-reply would sent to no-reply@mydomain.com. Right?
So with that script I would loose the address of the sender and would not be able to answer to the mail.
YOU can use reply to reply to the list but you can not reply directly to the person who sent the mail to the list. Your account auto-reply uses the Return-Path (com api FromAddress) to send its auto reply to. So you can change the script to do what you like.

It depends how you are using this distribution list. If its for notifications and you don't want replies to the list, then there's no harm in using the senders email address in the Return-Path or no-reply@domain.com and putting the senders email address in From: so anyone wanting to reply to the snder directly can. Its upto you. Play with it and see what you get.

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

Re: no auto-reply in distributionlists

Post by mattg » 2016-07-20 00:36

mattg wrote:I think an easier way...

Create an account say sales@acme.org
Set this account to forward to sales.list@acme.org
Do not keep a copy

Where sales.list is your distribution list

When Autoreplies are made they are not sent back to the original sender

It does slow the process down for 1 minute (as the forward happens exactly after a minute), but if you can live with that this could work for you
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

Re: no auto-reply in distributionlists

Post by chris0602 » 2016-07-20 12:11

mattg wrote:
mattg wrote:I think an easier way...

Create an account say sales@acme.org
Set this account to forward to sales.list@acme.org
Do not keep a copy

Where sales.list is your distribution list

When Autoreplies are made they are not sent back to the original sender

It does slow the process down for 1 minute (as the forward happens exactly after a minute), but if you can live with that this could work for you
I've tested your recommendation and it worked, but the setup is to complex (setting for every list an account with forwarding and holding many dummy accounts). I would like that feature for all distributionlists not only for some. But I keep that solution in mind if I don't find a better for me.
jimimaseye wrote:SCRIPT:
when receiving an email at account level, check to see if the account address it comes has auto-reply enabled. IF YES:....

.... then check it belongs a distribution list (stick all distribution lists that the address belongs to in an array (eg, the address is found to belong in DIST1@ and DIST2...).

Then check to see if those distribution lists in the array is addresses in the email recipients list. If any of them are, then the conclusion is that this email came in via distribution list. THEN... modify that email and append a keyword to the subject (eg, "DISTNOREPLY").

Then, you have a global rule:

where FROM is local (ie, its not from external address) and
SUBJECT contains "DISTNOREPLY" (ie, its from one of the matching emails above come in by distribution list) and
has a AUTO-SUBMITTED header (ie, it came from an auto-reply message)

then delete message. This will prevent those out of office messages getting delivered. (It wont affect the original inbound message because that will not have the "DISTNOREPLY" marker).


If an email came in directly to the account (not by distribution list address) then it will be 'auto-replied' as normal because the "DISTNOREPLY" keyword will not be present.

Just a script and a rule. (Avoids guess work about who and when return-paths get used, or fromaddresses or who the sender was. It just gets on with deleting the outgoing auto-reply to whoever it was destined to).
Thanks for your detailed explanation. But that Script would only work if the subject of the mail is also used for the auto-reply. right?
We have most an "out of office" subject set which can set by every user individually. So the "DISTNOREPLY" keyword would be removed from the subject of the auto-reply.

If there is no chance to set a custom header to the incoming mail which will be also used for the auto-reply mail I don't see a good solution for me.

Maybe it's more simple to change the behaviour of auto-reply in the source. I'll take next time a look at it.

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

Re: no auto-reply in distributionlists

Post by jimimaseye » 2016-07-20 12:38

chris0602 wrote:Thanks for your detailed explanation. But that Script would only work if the subject of the mail is also used for the auto-reply. right?
We have most an "out of office" subject set which can set by every user individually. So the "DISTNOREPLY" keyword would be removed from the subject of the auto-reply.
Yes it would depend on the %subject% macro being included in the Subject. (eg, "Out Of Office - %subject%"). But if you dont want to force that on the users (who set their own subjects and might forget to apply "%subject%"), then why not simply append the word "DISTNOREPLY" to the end of the email body as the last word? (or any other word/symbol combination that you think may be unique enough to never appear at any other time and yet is small or insignificant enough to mean nothing to anyone). Add it like a footer:

<NL>
<NL>
NODISTREPLY


(adding it as htmlbody you can even make it small enough to barely appear readable).

After all, it only gets added

a, when coming in via a distribution list AND
b, when auto-reply is set.


For your information, here is a genuine footer that appears on emails from one of our customers

DISCLAIMER
This email is confidential and subject to important disclaimers and conditions in relation to monitoring, viruses, confidentiality and legal privilege full details of which can be viewed on our Email Policy at the following link: http://www.next.co.uk/Policy/EmailPolicyStatement.asp

Next Group plc registered in England 35161. Registered Office Desford Road Enderby Leicester LE19 4AT. Authorised and regulated by the Financial Conduct Authority

NXTSTDDIS
You see they already have a similar word right at the bottom of it. It means nothing to us but they always add it. Doesnt look too bad. Now I see where my inspiration came from.

By the way: Im not sure how you get your users to set their own auto-replies but this script allows them to do it by means of an email and you get to control/enforce the %subject% macro being used by setting parameter IncludeSubject = "YES "(so it will not be forgotten). It also means they do not have to use web browsers and all can be done just with an email.
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

chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

Re: no auto-reply in distributionlists

Post by chris0602 » 2016-07-20 14:59

jimimaseye wrote:Yes it would depend on the %subject% macro being included in the Subject. (eg, "Out Of Office - %subject%"). But if you dont want to force that on the users (who set their own subjects and might forget to apply "%subject%"), then why not simply append the word "DISTNOREPLY" to the end of the email body as the last word? (or any other word/symbol combination that you think may be unique enough to never appear at any other time and yet is small or insignificant enough to mean nothing to anyone). Add it like a footer:
That's the same problem. The Body is also not append to the auto-reply.

But maybe that will work:
Add the %subject% macro to auto-reply subject if a message is found which should not replied.
Then remove %subject% from subject when the auto-reply message is deleted.

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

Re: no auto-reply in distributionlists

Post by jimimaseye » 2016-07-20 16:37

chris0602 wrote:
jimimaseye wrote:Yes it would depend on the %subject% macro being included in the Subject. (eg, "Out Of Office - %subject%"). But if you dont want to force that on the users (who set their own subjects and might forget to apply "%subject%"), then why not simply append the word "DISTNOREPLY" to the end of the email body as the last word? (or any other word/symbol combination that you think may be unique enough to never appear at any other time and yet is small or insignificant enough to mean nothing to anyone). Add it like a footer:
That's the same problem. The Body is also not append to the auto-reply.
Doh!! :oops: I was having a little brain fade there.

But yes, you could do the "is it to a distribution list" test in the script, modify the existing auto-reply subject to add the %subject% macro if needed. The question is how do you then catch the point in time AFTER the reply has been generated to then change it back (so as not to change it back before the reply has been generated).

(There is often a benefit in a standard policy being implemented that people cannot over-rule - and if it was policy to ALWAYS include the original subject in the OutOfOffice reply (eg "Out Of Office - original subject") then you wouldnt have this problem. After all, does it really matter? And whats more I would think having the original subject is better for the original sender to know what email the reply is responding to in case they were firing off multiple emails. As an end user, they will just deal with whatever system they have been given and if you append the %subject% macro in all cases with the idea that *thats the only way, it's policy*, lets face it, they will never ever see it and will ne....verr....know....... Mwa-ha-ha-haa-haaaaa.... )
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

chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

Re: no auto-reply in distributionlists

Post by chris0602 » 2016-07-21 09:57

jimimaseye wrote:But yes, you could do the "is it to a distribution list" test in the script, modify the existing auto-reply subject to add the %subject% macro if needed. The question is how do you then catch the point in time AFTER the reply has been generated to then change it back (so as not to change it back before the reply has been generated).
My idea was to change it back when the auto-reply is catched from the script.
Then delete the auto-reply mail + remove %subject%.

I will try it next week and will give you a response if that worked.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: no auto-reply in distributionlists

Post by percepts » 2016-07-21 15:14

there may be a much simpler and more logical way of hnadling this depending on which type of distribution list/list you are running.

If they are all notification lists where there is only one email address which is allowed to post to the list/lists then its easy to handle. If anyone can post to the lists then its more tricky.

So which type of list/lists are you using:

Public
Memebership
Announcements

so please tell us which of the above you are using. One or more of each or just annoucement type?

If its just annocements then I would create a special email address for the list, say listadmin@mydomain.com and then you are forced to use that address to send to the list. And you include that adsress in the members list. That means any replies for you the sender, auto or otherwise will always come back to that to that address.

Then you should know that auto reply adds an auto reply header to the auto reply mail which is:

Auto-Submitted: auto-replied

So then what you do is create an account level rule(not global) in listadmin@mydomain.com which says:

criteria: custom header / Auto-Sumitted contains auto-replied
action: delete email

do not stop rule processing (see below)

then you have two choices, you either setup your email client to collect mails sent to listadming@mydomain.com or you create a second rule positioned after the above rule which forwards any email sent to listadmin@mydomain.com to your own personal email address and delete the mail. So again in account level rules it would be be:

criteria: message size > 0
action: Forward to mypersonalemail@mydomain.com
delete email

If you are using public or membership lists then its more tricky but theres no need to get into that if you are not using them, so let us know.

The big benefit of what I suggest above is that it doesn't require any scripting but public or membership lists are problematic becasue an auto reply doesn't include any of the original list email body or headers so there is nothing to test for. The only way you can force that to happen is to script similar to what I posted originally so that if the mail is addressed to listadmin and Auto-Submitted header exists you can delete the email.

One potential problem is what order specific email clients decide to to use as the reply addresses, Return-Path, Reply-To or From. I don't think they all use the same. some may use From: before Reply-To etc so you need to force these headers to be something which will always get replied to the listadmin address.

If you are using membership lists and you want the reply (not auto reply) to goto the member who sent the mail and not the list then you have a problem because auto-reply will use the same address and not the listadmin address unless you force it to the list.

None of this is a problem if you are only using annoucement type lists and the method I suggested above using only rules will work. Similar to what matt suggested except the rules actually delete the auto reply email and don't leave it in the data folder with nowhere to go.

To stop any auto replies being sent to the list you should add a global rule which says

criteria: To contains listaddress@mydomain.com (note: this is not listadmin address)
custom header / Auto-Sumitted contains auto-replied
action: delete email

For membership lists you as the listadmin address wouldn't get any auto replies. Other members would.

chris0602
New user
New user
Posts: 20
Joined: 2008-04-02 16:23

Re: no auto-reply in distributionlists

Post by chris0602 » 2016-07-21 17:26

Thanks you all for the Support!!!

now I have written a script that works fine for me. It's not perfect because it can cause problems if two auto-replys should send at same time from the same account but that will not happen so often.

All mails which didn't where addressed to a specific account (distributionlists, auto-forwards) and redirect to an account which set auto-reply no reply mail is sent. If the replying account is directly addressed the reply mail is send.

If somebody is interested in the code...

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
  Dim obApp
  Dim obDomain 
  Dim oAccount
  Dim tmp
  Dim i
 
 'check all recipients in a loop
  For i = 0 to oMessage.Recipients.Count -1
    'check if is addressed to a account
    If oMessage.Recipients.Item(i).IsLocalUser = true and oMessage.Recipients.Item(i).OriginalAddress <> oMessage.Recipients.Item(i).Address Then      
      Set obApp = CreateObject("hMailServer.Application")   
      Call obApp.Authenticate("Administrator", "password")
      Set obDomain = obApp.Domains.ItemByName("mydomain.com")
      Set oAccount = obDomain.Accounts.ItemByAddress(oMessage.Recipients.Item(i).Address)
      'check is auto-reply is set for that account
      If oAccount.VacationMessageIsOn = True then
        'prepare the subject of auto-reply
        tmp = Split(oAccount.VacationSubject, "DISTNOREPL")
        oAccount.VacationSubject = tmp(0) & "DISTNOREPL" & oMessage.FromAddress
        oAccount.Save()
        EventLog.Write("Account mit Autoantwort: " & oMessage.Recipients.Item(i).Address & " aus Verteilerliste: " & oMessage.Recipients.Item(i).OriginalAddress)
      End If
    End If
  Next
  Result.Value = 0
End Sub

Sub OnDeliveryStart(oMessage)
  Dim obApp
  Dim obDomain 
  Dim oAccount
  Dim tmp
  
  'check if subject of auto-reply is prepared to not be sent
  If InStr(oMessage.Subject, "DISTNOREPL") Then
    Set obApp = CreateObject("hMailServer.Application")   
    Call obApp.Authenticate("Administrator", "password")
    Set obDomain = obApp.Domains.ItemByName("mydomain.com")
    
    Set oAccount = obDomain.Accounts.ItemByAddress(oMessage.FromAddress)
    
    tmp = Split(oAccount.VacationSubject, "DISTNOREPL")
    oAccount.VacationSubject = tmp(0)
    oAccount.Save()
    'check if the recipient of the auto-reply is the same in the prepared subject
    If tmp(1) = oMessage.Recipients.Item(i).Address Then 
      
      EventLog.Write("Autoantwort wurde gelöscht: " & oMessage.FromAddress)
      Result.Value = 1
    Else
      oMessage.Subject = tmp(0)
      oMessage.Save()
      Result.Value = 0
    End If
    
  Else
    Result.Value = 0
  End If
  
End Sub

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

Re: no auto-reply in distributionlists

Post by jimimaseye » 2016-07-21 18:22

Looks like a suitable solution. I think the chances of you:

a, receiving two or more emails
b, from two or more different senders
c, that have never already had an out of office reply before
d, and one of those being a distribution list whilst the other is not
e, and at exactly the same time (split second)

is highly unlikely. And even if it did happen, the worse case is the out of office message doesnt get received back to the original sender of the directly addressed email. (No big shocker - your user as the recipient still got their mail which is the important part).
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

Post Reply