EmailDiscussions.com

EmailDiscussions.com (http://www.emaildiscussions.com/index.php)
-   FastMail Forum (http://www.emaildiscussions.com/forumdisplay.php?f=27)
-   -   sieve script for blocking mailchimp to specific alias email (http://www.emaildiscussions.com/showthread.php?t=74094)

ferrety 14 Dec 2018 02:42 AM

sieve script for blocking mailchimp to specific alias email
 
How would I write a rule for sieve to stop ALL mail being sent to a specific alias email via mailchimp. Alias email has to be in the semi-public domain so no point changing it but certain organisations are begging me for money via mailchimp. If you need the raw data info let me know which bit. thx

BritTim 14 Dec 2018 05:18 AM

When constructing complex sieve rules, you need to carefully examine the headers of the messages you want to manipulate. Perhaps, you could post the headers of two representative messages,, obscuring personally identifiable information. (I suggest changing the part of an email address that identifies an individual account to something like '<my-account>', '<sender's-account>').

somdcomputerguy 14 Dec 2018 11:01 AM

When a particular email is opened to be read, click on the 'more' dropdown and then the 'Add rule from message' choice. The 'Mailing List ID' spec should already be one of the conditions, then click the 'Add Condition' button and add the specific email address that you want this rule to apply to.

If that doesn't work, you can delete the 'ID' condition, and add one like this:

https://monosnap.com/file/Kag0BI2Cee...jz4Xs37WpHhFKz

This is what I'd do, hopefully it works for you as well.

- Bruce

edit: if it's a legitimate mailing list email, perhaps just unsubscribe from it..

ferrety 15 Dec 2018 02:18 PM

Quote:

Originally Posted by BritTim (Post 608555)
When constructing complex sieve rules, you need to carefully examine the headers of the messages you want to manipulate. Perhaps, you could post the headers of two representative messages,, obscuring personally identifiable information. (I suggest changing the part of an email address that identifies an individual account to something like '<my-account>', '<sender's-account>').

I'm not posting the whole thing because I'm scared I'll inadvertently leave something identifying. And the header seems massive. :eek:But I'll post the message ID bit that mentions mailchimp. I don't know if that will help, sorry. If you could tell me if this could be weaved into a sieve rule I'd be grateful:)


Quote:

Message-ID: <152059abb172ad0a48146755e.02935a2d5d.20181213181416.2ed67ca2db.21a06e7b@mail70.atl31.mcdlv.net>
X-Mailer: MailChimp Mailer - **CID2fd97ca2db05035a2d5d**
X-Campaign: mailchimp152059abb172ad0a48146755e.2fd97ca2db
X-campaignid: mailchimp152059abb172ad0a48146755e.2fd97ca2db
Would this work, feel free to laugh if it is badly wrong

if header :contains "X-Mailer" ["MailChimp"]

{reject }

BritTim 15 Dec 2018 03:33 PM

You can create a rule based on the To alias and the X-Mailer header.

Go to Settings->Rules, click New rule, and use
Code:

If all of the following conditions apply
Any recipient email  is exactly  <the desired alias>

(Add condition)
Code:

A header called  X-Mailer  begins with  MailChimp Mailer
Under Action select
Permanently delete the message

Then click Save

ferrety 15 Dec 2018 05:19 PM

Quote:

Originally Posted by BritTim (Post 608567)
You can create a rule based on the To alias and the X-Mailer header.

Go to Settings->Rules, click New rule, and use
Code:

If all of the following conditions apply
Any recipient email  is exactly  <the desired alias>

(Add condition)
Code:

A header called  X-Mailer  begins with  MailChimp Mailer
Under Action select
Permanently delete the message

Then click Save

Thanks Tim:) appreciated would you be willing to give me the sieve script for it?

ferrety 15 Dec 2018 05:33 PM

Quote:

Originally Posted by BritTim (Post 608567)
You can create a rule based on the To alias and the X-Mailer header.

Go to Settings->Rules, click New rule, and use
Code:

If all of the following conditions apply
Any recipient email  is exactly  <the desired alias>

(Add condition)
Code:

A header called  X-Mailer  begins with  MailChimp Mailer
Under Action select
Permanently delete the message

Then click Save

Thanks Tim:) appreciated would you be willing to give me the sieve script for it? Also I'm trying to learn so if I wanted to stop mailchimp sending to all emails (rather than a specific alias) would this be correct?


Quote:

if header :contains ["X-Mailer"] ["MailChimp"]

{discard; stop;}

BritTim 15 Dec 2018 07:56 PM

Quote:

Originally Posted by ferrety (Post 608569)
Thanks Tim:) appreciated would you be willing to give me the sieve script for it?

Usually, the best way of figuring out the sieve code for something that can be done using a Rule is to
  • Create the Rule
  • Go to Edit custom sieve code (see bottom right of the page)
  • Find the sieve code associated with the Rule you just created.
  • Copy the code.
  • Cancel to exit from Custom Sieve and delete the Rule you created temporarily.
Doing this for your problem, you get
Code:

if
  allof(
  address :is ["To","Cc","Resent-To","X-Delivered-To"] "MyAlias@MyDomain.com",
  header :matches "X-Mailer" "MailChimp Mailer*"
  )
{
  discard;
  stop;
}


xyzzy 17 Dec 2018 05:16 PM

I do what was just described. But I always keep the rule disabled at the start of the list of rules to make it easier to spot in the sieve script. It will be the first rule that's is always commented out. No need to go back and delete it.

ferrety 17 Dec 2018 05:29 PM

Quote:

Originally Posted by BritTim (Post 608571)
Usually, the best way of figuring out the sieve code for something that can be done using a Rule is to
  • Create the Rule
  • Go to Edit custom sieve code (see bottom right of the page)
  • Find the sieve code associated with the Rule you just created.
  • Copy the code.
  • Cancel to exit from Custom Sieve and delete the Rule you created temporarily.
Doing this for your problem, you get
Code:

if
  allof(
  address :is ["To","Cc","Resent-To","X-Delivered-To"] "MyAlias@MyDomain.com",
  header :matches "X-Mailer" "MailChimp Mailer*"
  )
{
  discard;
  stop;
}


Hi Tim
Really appreciate your knowledge here
Will the script I wrote fail, if so what about it have I messed up. Again forgetting aliases (so as to make it less complicated)?

PS I signed up for a free mailchimp account (giving the spammy gits no private info) I used an alias email & sent my self test emails while fiddling with sieve script. To test if my script was stopping them.
It only started stopping them when I set it like below
Quote:

if header :contains ["X-Mailer"] ["MailChimp"]

{discard; stop;}

BritTim 18 Dec 2018 03:46 PM

Quote:

Originally Posted by ferrety (Post 608606)
Hi Will the script I wrote fail, if so what about it have I messed up. Again forgetting aliases (so as to make it less complicated)?

Your simpler version will likely not have issues. However, it is best not to be sloppy with things like sieve code, and be very specific in the conditions you want to test. People have often run into trouble in the past by having their rules unexpectedly match something other than what was intended. You probably do not need to change your code here. However, for the future, I would recommend using Rules or (if, for some reason you cannot in a specific situation) being very careful and specific about your tests.

ferrety 18 Dec 2018 11:33 PM

Quote:

Originally Posted by BritTim (Post 608609)
Your simpler version will likely not have issues. However, it is best not to be sloppy with things like sieve code, and be very specific in the conditions you want to test. People have often run into trouble in the past by having their rules unexpectedly match something other than what was intended. You probably do not need to change your code here. However, for the future, I would recommend using Rules or (if, for some reason you cannot in a specific situation) being very careful and specific about your tests.

Really appreciate the advice, I wish there was an ebook sieve for dummies on it. I find it fascinating but don't really understand it. Thus the sloppy script :)

janusz 19 Dec 2018 02:33 AM

https://www.howtoforge.com/sieve_mail_filtering


All times are GMT +9. The time now is 02:26 AM.


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