EmailDiscussions.com

EmailDiscussions.com (http://www.emaildiscussions.com/index.php)
-   FastMail Forum (http://www.emaildiscussions.com/forumdisplay.php?f=27)
-   -   Blocking emails from specific domain (http://www.emaildiscussions.com/showthread.php?t=73657)

ferrety 27 Mar 2018 06:56 PM

Blocking emails from specific domain
 
Is it possible with fastmail (standard account) to set up a rule or something to reject emails from a specific domain.
I don't want them to go into spam I want them to bounce back to the sender as rejected. I want them to know the email hasn't reached me.

So I could for example allow normal amazon emails through but stop marketplace sellers contacting me, begging for reviews etc (sometimes years after a purchase).

So could I say, bounce stuff coming from @marketplace.amazon.co.uk but allow normal Amazon system emails through (these have a different domain)

Please no lectures about complaining to Amazon, thanks it is just an example :)

n5bb 28 Mar 2018 02:51 PM

Rejection of specified messages
 
Yes, this is possible. But you should be very careful about such rules, since you can block desired messages if you are not careful. Here are the steps:
  • Go to Settings>Rules and at the bottom right click Edit custom sieve code.
  • In the first (Insert sieve code here) block (before the ### 1. section) enter sieve code similar to the following:
    Code:

    if address :domain :is ["X-Mail-from"] ["marketplace.amazon.co.uk","example.org"]
    {
      reject "Mailbox does not exist";
      stop;
    }

  • Click Save at the top.
Any incoming message sent from any domain in the square brackets will be rejected (and discarded so it does not appear in your Fastmail mailbox). You can place one or more domains (in double quotes as shown) to be rejected in the square brackets. Be sure to look at the raw message and examine the X-Mail-from header in existing emails sent from the domain you want to block and use the exact domain shown (everything after but not including the @). If you use more than one domain you need to separate them with a comma as shown. A reject message will be sent to the sender as follows:
  • From: Mail Sieve Subsystem <postmaster@messagingengine.com>
  • To: (the From or possibly another reply-to address used by the original sender)
  • Subject: Automatically rejected mail
  • Message body:
    Code:

    Your message was automatically rejected by Sieve, a mail
    filtering language. 

    The following reason was given:
    Mailbox does not exist

  • The last line of the body is whatever text you place in the reject clause in the sieve code.
  • Two attachments are also returned in the rejection message. One is the original message. The other shows technical details about the rejection.
Bill

ferrety 28 Mar 2018 02:54 PM

Quote:

Originally Posted by n5bb (Post 606008)
Yes, this is possible. But you should be very careful about such rules, since you can block desired messages if you are not careful. Here are the steps:
  • Go to Settings>Rules and at the bottom right click Edit custom sieve code.
  • In the first (Insert sieve code here) block (before the ### 1. section) enter sieve code similar to the following:
    Code:

    if address :domain :is ["X-Mail-from"] ["marketplace.amazon.co.uk","example.org"]
    {
      reject "Mailbox does not exist";
      stop;
    }

  • Click Save at the top.
Any incoming message sent from any domain in the square brackets will be rejected (and discarded so it does not appear in your Fastmail mailbox). You can place one or more domains (in double quotes as shown) to be rejected in the square brackets. Be sure to look at the raw message and examine the X-Mail-from header in existing emails sent from the domain you want to block and use the exact domain shown (everything after but not including the @). If you use more than one domain you need to separate them with a comma as shown. A reject message will be sent to the sender as follows:
  • From: Mail Sieve Subsystem <postmaster@messagingengine.com>
  • To: (the From or possibly another reply-to address used by the original sender)
  • Subject: Automatically rejected mail
  • Message body:
    Code:

    Your message was automatically rejected by Sieve, a mail
    filtering language. 

    The following reason was given:
    Mailbox does not exist

  • The last line of the body is whatever text you place in the reject clause in the sieve code.
  • Two attachments are also returned in the rejection message. One is the original message. The other shows technical details about the rejection.
Bill

You are a genius, I'll not be able to try this till later today. I'll be back :):D

ferrety 28 Mar 2018 03:14 PM

Bill
I just tried this (thinking I would mess it up) using a throw away outlook email I'd set up so I could see what they would get back
Sure enough it worked, you sir are fantabulous!:D

ferrety 3 Apr 2018 05:57 PM

Bill
If I want to block more than one domain but want to have them receive different reject reasons can I do it like this? Is there a limit to how many I can do?

if address :domain :is ["X-Mail-from"] ["marketplace.amazon.co.uk"]
{
reject "Unwanted Spam From Amazon Marketplace seller";
stop;
}


if address :domain :is ["X-Mail-from"] ["trustpilot.com"]
{
reject "Trustpilot are not authorised to have this email address";
stop;
}

BritTim 4 Apr 2018 03:57 AM

Quote:

Originally Posted by ferrety (Post 606074)
Bill
If I want to block more than one domain but want to have them receive different reject reasons can I do it like this? Is there a limit to how many I can do?

if address :domain :is ["X-Mail-from"] ["marketplace.amazon.co.uk"]
{
reject "Unwanted Spam From Amazon Marketplace seller";
stop;
}


if address :domain :is ["X-Mail-from"] ["trustpilot.com"]
{
reject "Trustpilot are not authorised to have this email address";
stop;
}

You can do that. There is no practical limit on the length of the sieve snippets you can write.

ferrety 4 Apr 2018 02:04 PM

Quote:

Originally Posted by BritTim (Post 606078)
You can do that. There is no practical limit on the length of the sieve snippets you can write.

Really appreciated I've been googling it for days:)

n5bb 4 Apr 2018 02:21 PM

Automated reject messages are usually a bad idea
 
I just realized that I made a mistake in my earlier instructions. You should insert the sieve reject code in the second user sieve block (after the ### 3. Sieve generated for spam protection block). In general, it's a bad idea to automatically respond to messages which trigger the spam filter, so you want your reject sieve code after the spam filter. The reason will be described later in this post.

Yes, you can respond to multiple From sending domains as you described with different response messages. But you might not want to send all of those reject messages back to the senders. Consider several types of messages you could receive from those sending domains:
  • Spoofed From address:
    • Blatant spammers and those sending phishing messages and malware will often use a fake From address.
    • They don't want you to respond to them via email. They want you to click a link, open an attachment, or follow some instructions in the message (such as buying a penny stock). They are only sending, and have no need to receive email for their purposes.
    • So the bad guys use a spoofed (fake) From address which is less likely to be blocked as spam. They might happen to use a From domain you are rejecting. So your rejection messages might be returned to innocent people whose email domain happens to be one you reject.
    • This can lead in some cases to your email address, your email domain, or the SMTP server you send from being blocked. The block could be at that one domain, or in severe cases it could make it to blacklists or greylists of some type.
    • This is why you need to place the reject sieve code after your spam filter (and always use the Fastmail spam filter). If a message is classified as spam, you want to ignore the message and never respond to it!
  • Automated message sent to you from a sender who is moderately trustworthy.
    • Your reject message will probably be ignored. So why send it, since it might be a spoofed spam message as I described above?
    • If there is an Unsubscribe procedure at the bottom of the message, you can use that procedure. I would check the authentication headers in the message and see if it appears to be truly from the supposed From source before clicking any links in the message.
  • Manually created message sent to you from a sender who is moderately trustworthy.
    • You suspect the sender will actually read your response. In this case, a manual or automatic response to the sender might be appropriate.
In nearly all cases, I think it's better to discard such messages rather than reject them with an automated reply. The rejection message might make you think you are getting back at the sender, but in nearly all cases a rejection reply will potentially hurt you more than the sender.

Bill

ferrety 4 Apr 2018 02:33 PM

Quote:

Originally Posted by n5bb (Post 606083)
I just realized that I made a mistake in my earlier instructions. You should insert the sieve reject code in the second user sieve block (after the ### 3. Sieve generated for spam protection block). In general, it's a bad idea to automatically respond to messages which trigger the spam filter, so you want your reject sieve code after the spam filter. The reason will be described later in this post.

<snip>

Bill

I appreciate your input thank you again :)
I absolutely do NOT want this going to spam though. I absolutely DO want to see them get a personalised reject message. So it will work if I put it before the ### 1. section right?


All times are GMT +9. The time now is 04:10 AM.


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