Score:0

Reject mail based on FROM domain

tr flag

I'm wondering if it's possible to setup filter in sieve to catch the FROM domain and match that with the TO recipient mailbox name.

Usage is to filter unwanted emails when companies sell/share my personal information.

ex.

This should be accepted:

FROM: [email protected]
TO: [email protected]

This should be rejected:

FROM: [email protected]
TO: [email protected]
Score:0
za flag

Probably you need "allof" operator, which is boolean "and" for several tests. Something like this:

require ["fileinto", "mailbox"];
if allof
    (
        address "To" "[email protected]",
        address "From" "[email protected]"
    )
{
     fileinto "INBOX.Trash";
}

Notice, it is bad idea to reject on this stage, because it will generate a bounce and this is often not desired. The mail is already accepted by the time it is given to Sieve, so you can move it to spam or to trash, discard (silently delete) and so on, but don't reject.

Also notice that "To" and "From" headers from the mail can easily be forged. I'll be able to circumvent this filter by setting correct envelope address and faking the "To" header inside the mail to something other. It is envelope address (specified in the SMTP "RCPT To" command rather than the message header) controls which mailbox the mail gets delivered into. To test against envelope addresses, use the word "envelope" instead of "address" in the test, and also require "envelope" Sieve module.

See for example here for details.

tr flag
Alright cool, thanks for the reponse! do you know if it's possible to actually catch/split the origin sender domain into a variable to be used to match the destination mailbox name? meaning, to have it more dynamic and not static.
Nikita Kipriyanov avatar
za flag
Did you try any research [by yourself](https://bfy.tw/T8th)?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.