Score:0

Exim filter check if email is forwarded

nz flag

I'm using Exim with Cpanel. I created email forwarding from '[email protected]' to '[email protected]' and '[email protected]' to '[email protected]'.

I want to filter only emails that are forwarded so if a user sends an email to '[email protected]' no thing would happen but on forwarding this email to '[email protected]' I want to filter it.

I can't do that:

if ("$h_to:, $h_reply_to:" contains "[email protected]")

because I don't want to target emails sent directly to '[email protected]'.

I tried to create .forward file in /home/ and in /home/user/ but it's not doing anything.

I created a filter file:

touch /usr/local/cpanel/etc/exim/sysfilter/options/forward_filter

and enabled it I just need the condition to target the forwarded emails only.

jp flag
Wouldn't it be better to handle this in a *message delivery agent* (MDA) like Sieve or Procmail?
in flag
If the forwarding is done by Exim, you can set any `r_*` variable in the `redirect` driver, and check for that variable in the ACLs (specifically in `predata`, `data`, and `data_prdr`). You can add headers to the message in the ACLs, which makes it trivial to filter the messages later in any MDA. Unfortunately I don't know how to specify all of these when cPanel is involved, but there might be similar settings.
mm1234 avatar
nz flag
@EsaJokinen I'm new to Linux servers and I think Cpanel doesn't have any of these MDA. Is it possible to add one of them to work with Cpanel and Exim?
mm1234 avatar
nz flag
@Lacek Actually I want to use filters to add/remove headers because forwarding is not working with SES as the sender email has to be verified. So if an email is forwarded from '[email protected]' to '[email protected]' it won't be forwarded as '[email protected]' is not verified with SES as it's impossible to verify all users sending us emails.
jp flag
We don't really deal with web hosting control panels here, so I don't know what's possible. We know about configurating the actual server software. Unfortunately, I know more about Postfix than Exim.
mm1234 avatar
nz flag
@EsaJokinen Thanks, I tried to update the headers most of them are updated except `Return-Path` and `Received` SES SMTP still detects the sender email somehow maybe from `Return-Path` although I removed it and added a new one but it exists like 3 times 2 of them from the real sender
I sit in a Tesla and translated this thread with Ai:

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.