Jump to content

This is the support site for Andrews & Arnold Ltd, a UK Internet provider. Information on these pages is generally for our customers but may be useful to others, enjoy!

Sieve-Example:Move email to a suffix folder: Difference between revisions

Content deleted Content added
AA-Andrew (talk | contribs)
Adsb (talk | contribs)
m Refreshing folder list (e.g. Thunderbird)
Tags: Mobile edit Mobile web edit
 
(4 intermediate revisions by 2 users not shown)
Line 40: Line 40:
## Move messages sent to an address with a suffix eg, me-amazon@example.com in to a folder called Filtered/amazon, if it exists.
## Move messages sent to an address with a suffix eg, me-amazon@example.com in to a folder called Filtered/amazon, if it exists.
if exists "X-Delivered-To" {
if exists "X-Delivered-To" {

if header :regex "X-Delivered-To" "-([A-z0-9]+)@" {
if header :regex "X-Delivered-To" "-([A-z0-9]+)@" {
set "suffix" "${1}";
set "suffix" "${1}";
fileinto "INBOX.Filtered.${suffix}";
fileinto "INBOX.Filtered.${suffix}";
stop;
}
}
}
stop;}
</syntaxhighlight>
</syntaxhighlight>


*This filter uses the 'X-Delivered-To' header which is added by the A&A mail servers - even if you are BCC'd then the filtering will work. The X-Delivered-To is the 'envelope-to' header, which is the address the email was actually sent to by the sender (in lowercase).
*This filter uses the 'X-Delivered-To' header which is added by the A&A mail servers - even if you are BCC'd then the filtering will work. The X-Delivered-To is the 'envelope-to' header, which is the address the email was actually sent to by the sender (in lowercase).
*You'll need to add this sieve filter - eg by using the (latest) Thunderbird Sieve extension, see [https://support.aa.net.uk/Sieve_Filtering#Sieve_Server_Settings Sieve_Server_Settings] for info in the 'Creating Sieve Filters' section
*You'll need to add this sieve filter - eg by using the (latest) Thunderbird Sieve extension, see [https://support.aa.net.uk/Sieve_Filtering#Sieve_Server_Settings Sieve_Server_Settings] for info in the 'Creating Sieve Filters' section
*This won't be able to be added via Roundcube, as you can't paste in raw sieve code there.
*To add via Roundcube, select 'Actions', 'Edit filter set'.


===Variations===
===Variations===
You can create the folders automatically if you wanted add :create, - but some mail clients won't refresh their folder list until they are restarted. We also title case the new folder name - eg it will be called Amazon (capital A).
You can create the folders automatically if you wanted add :create, - but some mail clients won't refresh their folder list until they are restarted, or the folder list collapsed and reopened. We also title case the new folder name - eg it will be called Amazon (capital A).
<syntaxhighlight lang="sieve">
set :upperfirst "suffix" "${1}";
set :upperfirst "suffix" "${1}";
fileinto :create "INBOX.Filtered.${suffix}";
fileinto :create "INBOX.Filtered.${suffix}";
</syntaxhighlight>

If you're using a + rather than a - to separate the suffix, then adjust the regex in the sieve filter above to be like:
If you're using a + rather than a - to separate the suffix, then adjust the regex in the sieve filter above to be like:
<syntaxhighlight lang="sieve">
if header :regex "X-Delivered-To" "\\+([A-z0-9]+)@" {
if header :regex "X-Delivered-To" "\\+([A-z0-9]+)@" {
</syntaxhighlight>


== Create the folders ==
== Create the folders ==
Line 69: Line 72:


[[Category:Sieve]]
[[Category:Sieve]]
[[Category:Email How to]]