EmailDiscussions.com

EmailDiscussions.com (http://www.emaildiscussions.com/index.php)
-   FastMail Forum (http://www.emaildiscussions.com/forumdisplay.php?f=27)
-   -   Contact groups in Sieve (http://www.emaildiscussions.com/showthread.php?t=74101)

Grhm 16 Dec 2018 08:42 AM

Contact groups in Sieve
 
When setting up the conditions of a rule, one of the options is "The sender is a member of group..."
But after setting up such a rule, I can find no reference to the group in the Sieve code.
Where I'd expect to find the name of the group there is instead a 36-character-long string of gobbledygook.
Can anyone explain this, please?
Also, when I try to set up a rule to forward mail to a group, it converts the group name to the current list of addresses of members of the group.
I can find no reference to groups in FM's Sieve help pages.
Is it possible genuinely to reference contact groups in rules and/or in Sieve?

BritTim 16 Dec 2018 09:09 AM

I have not looked in detail at how things work, but can perhaps provide some insight. Nothing you report is surprising.

The first thing to realise is that the sieve language has no concept of contact groups Also, for the most part, FastMail does not directly change the sieve processor itself. Building group support into FastMail involves translating contact groups into something the sieve processor understands.

For forwarding, it is natural to use the list of addresses comprising the group. For other purposes (involving checking for a header identifying a group) FastMail very likely wants to use a unique identifier across all users, rather than just the group name where the same name will often be used by many users.

Grhm 16 Dec 2018 09:34 AM

Thank you for your thoughts, Tim.

Quote:

Originally Posted by BritTim (Post 608580)
For forwarding, it is natural to use the list of addresses comprising the group

Well, yes... but that's only helpful if the membership of the group is static.
One would have to modify the script every time a member joined or left the group, which rather defeats the object of having a group in the first place.

Quote:

Originally Posted by BritTim (Post 608580)
For other purposes (involving checking for a header identifying a group) FastMail very likely wants to use a unique identifier across all users, rather than just the group name where the same name will often be used by many users.

This makes good sense, but I'm wondering whether the reference is genuinely to the group, or is it merely to the list of contacts who were members of the group at the instant the rule was encoded. If it's really to the group then might it be possible somehow to use the same 36-character code for forwarding?

n5bb 16 Dec 2018 10:45 AM

After some testing, I can confirm that that long tag string you see in the sieve script points to the group. As long as you don't delete the group it will be a unique pointer to that group. For example, the tag string remains unchanged under these conditions:
  • You can add or remove members of the group.
  • You can change the name of the group in the Settings>Contacts>Groups screen.
I can't find any security issues with these tag strings. For example:
  • Each time you create a group with a particular name, the tag string is unique. If you delete that group and later create a new group with the same name it will have a completely different tag string.
  • If you try using a tag string in sieve on a different Fastmail account, the tag string has no meaning in that different account (unless you have shared that group with other Fastmail accounts in a business).
Bill

Grhm 16 Dec 2018 11:05 AM

Wow, thank you Bill !
That is massively helpful, and encouraging.

BritTim 16 Dec 2018 12:13 PM

Quote:

Originally Posted by Grhm (Post 608581)
Quote:

Originally Posted by BritTim
For forwarding, it is natural to use the list of addresses comprising the group
Well, yes... but that's only helpful if the membership of the group is static.
One would have to modify the script every time a member joined or left the group, which rather defeats the object of having a group in the first place.

You identify why using rules is superior to trying to maintain sieve code manually. When a contact group is updated, FastMail will have arranged for your sieve script to be regenerated, using the current list of addresses within the contact group.

n5bb 16 Dec 2018 01:35 PM

As I stated, my tests indicate that the tag string in the sieve code does not change if you add or remove members from a group, or even if you rename a group. So you can either use the rules screen or use your own sieve script (with the same tag string for the group) and just change who is a member of that group. The sieve isn't automatically changed (because it doesn't need to be) when you edit the contacts in a group.

Address book groups are one of the best features of Fastmail. You can:
  • Manually compose a message to all members of a group by entering the group name in an addressing field.
  • In the Contacts screen, select all or only some of the member of a group and compose a message to them.
  • Set an alias to automatically deliver all messages sent to that alias to all members of a group.
  • Use rules based on whether the sender is in a certain group.
Bill

Grhm 16 Dec 2018 06:07 PM

Quote:

Originally Posted by n5bb (Post 608586)
the tag string in the sieve code does not change if you add or remove members from a group

...except that in the case Tim is referring to, a forwarding rule, for some reason the sieve generated from the rule doesn't appear to use the tag string - it converts the group name into a list of addresses instead.
l would have experimented to test Tim's theory that the seive is re-compiled every time the membership of a group changes, had Bill not reminded us that there's a much simpler way to forward mail to a group...
Quote:

Originally Posted by n5bb (Post 608586)
Set an alias to automatically deliver all messages sent to that alias to all members of a group.

Of course! Thank you, both.

BritTim 16 Dec 2018 07:33 PM

Indeed, Bill's solution is the correct one for forwarding to a group. For one thing, I had forgotten that a sieve redirect only allows you to specify a single address (something I had forgotten) so to achieve the trick with sieve would require a series of redirect :copy statements.

n5bb 17 Dec 2018 03:24 AM

Forwarding to contact group
 
There are two situations where we might like to use a contact group for automatic email processing:
  1. Incoming mail rules from members of a group: This was the original topic of this thread.
  2. Automatic forwarding of incoming messages to all members of a group: This can be done by setting the target of an alias to a group, as I mentioned earlier in this thread. But this bypasses spam filtering and the sieve rules system, and also requires us to set up special aliases and tell others to send to those specific aliases. So by itself this is not an ideal solution to this problem.
You can get around some (but not all) of the problems with #2 (automatic forwarding to a group) by using rules to forward certain messages to a special alias. I just tested this and it works fine if you are careful to not set up an email loop. Here is how to set this up:
  • Create a special alias which you will only use for sending messages to a group.
    • You must enter a delivery address, but in this case you don't want to deliver the message to your account since it may create an email loop. So I recommend you enter a plus+address such as user+noloop@youraccount.com and as shown below make changes to your rules to keep such messages from causing loops.
    • Choose to also deliver to all contacts in the desired contact group.
    • Restrict senders so that only FastMail users can send to this address. This prevents
    • Save the new or modified alias.
  • Create a rule specifying which messages will be forwarded to the group. You can't directly do this in sieve, since it doesn't understand address book groups. But you can create a rule as described below to forward the incoming message to your special alias described above.
    • Create a "all of the following conditions" rule with any conditions you wish to use to specify which messages are to be forwarded to the group.
    • Add a condition as follows:
      • A header called
      • X-Delivered-to
      • does not match glob pattern
      • *+noloop@*
    • The action should be to send a copy to your special alias, created as described above.
    • You can choose to Delete Permanently (only forward and discard the incoming message) or not (keep the incoming message as normal).
  • Now incoming messages which match your rule will be automatically forwarded to the special alias.
    • The alias will deliver the message to all contacts in the specified group.
    • Recipients of these forwarded messages will see the original From and To and Subject headers created by the original sender.
    • Depending on your choice to Delete Permanently described below, you can choose whether the message is delivered to your Inbox.
    • Because of the From address not aligning with the Fastmail server, it's quite possible that messages forwarded this way (and many other ways) will be marked as spam at the receiver.
Bill


All times are GMT +9. The time now is 02:31 PM.


Copyright EmailDiscussions.com 1998-2022. All Rights Reserved. Privacy Policy