Skip to main content

Global email filters override Default Address

Comments

10 comments

  • cPanelLauren
    Can you explain why my Default Address (Discard) is being overridden by filters?

    I think we'd need to see the rule before I can give you an answer to this, would it be possible for you to provide it?
    0
  • perplex
    I think we'd need to see the rule before I can give you an answer to this, would it be possible for you to provide it?

    Hello, I have many filters, is this of relevance? As I said it appears 'ANY' global filter rule that is added will override a users 'Default Address' Discard setting. I believe cpanel shouldn't work this way really, or there should be at least the option of placing the Default Address/discard above all filters. OK so anyway here's one of my rules - Filter Name: SPAM Body Body (matches regex): (?
    0
  • cPanelLauren
    I think I understand what's happening now, you're saying if the spam email matches some regex in the rule it's automatically sent to spam@my-domain.co.uk rather than (in the case of the default email) discarded. This is due to the way that exim processes these rules. The processing for this takes place prior to the processing for the discard of email sent to the default address so the forward to happens then I'd assume that the match on the default address is hit and the message to the default address is discarded (meaning it doesn't reach the default address, just the address you're forwarding to) this behavior is expected.
    0
  • perplex
    This is due to the way that exim processes these rules. The processing for this takes place prior to the processing for the discard of email sent to the default address so the forward to happens then I'd assume that the match on the default address is hit and the message to the default address is discarded (meaning it doesn't reach the default address, just the address you're forwarding to) this behavior is expected.

    Thanks for this, it's what I thought. Is there a way to get around this so that the Default Address (discard) is actioned prior to my filter rules? eg. Maybe creating a new 'regex' filter rule that mimics what cpanel Default Address/discard should be doing. Basically I would like a regex rule to: Filter Rule = Match all emails sent to: "does-not-exist@my-domain.co.uk" Action = Discard Action = Stop processing more rules It would be really great if some genius out there could come up with a solid solution as I've spent so many days trying resolve this with no joy. My regex skills a very limited and i've hunted high and low on Google too. Thanks! :-)
    0
  • cPanelLauren
    Hi @perplex What about something like this? (keep in mind this is an extremely simple example) if $message_body matches "REGEX HERE" and $header_to: does not contain "anotheraddresshere@email.tld" then deliver "user2@mydomain" finish endif
    0
  • perplex
    Hi Lauren, I was hoping that you could be a bit more specific if possible please, I'm not that great at regex especially of the Perl variety! I was looking for something like this - Email To (matches regex): If Does Not Match This (john OR peter OR luke @mydomain.co.uk) Action: Discard Eg. So john123@mydomain.co.uk would be discarded but john@mydomain.co.uk or peter@mydomain.co.uk or luke@mydomain.co.uk would be accepted for delivery. Many thanks!
    0
  • cPanelLauren
    In my example I was assuming you were using your own regex to determine if mail was to be forwarded as spam. Other than that, I gave you the entire rule I'm not sure what you mean by specific? The rule indicates if email matches "your regex" and isn't being sent to "your default address/es" then forward to your "spam email"
    0
  • perplex
    UPDATE: I've now managed to create a good regex rule to filter spam via cPanel email filters, I shall post it here to help others in my next response. I'm just adding final touches to it and wondered if anyone is able to tell me how to use 'word boundaries' in cpanel global email filters, I know cPanel uses PERL regex but I just can't get my code to work! Please show me how to match the text highlighted in red in the string below: Match: PCFkb2N9eXBlIGh0bWw+DQo8aHRt Perl Regex: What I have already: Fkb2N9.* What did not work: \BFkb2N9\B Basically if a spam email contains Fkb2N9 in a long Base64 string then I can deal with it, probably quarantine or disregard it as junk.
    0
  • CanUser
    I think I understand what's happening now, you're saying if the spam email matches some regex in the rule it's automatically sent to spam@my-domain.co.uk rather than (in the case of the default email) discarded. This is due to the way that exim processes these rules. The processing for this takes place prior to the processing for the discard of email sent to the default address so the forward to happens then I'd assume that the match on the default address is hit and the message to the default address is discarded (meaning it doesn't reach the default address, just the address you're forwarding to) this behavior is expected.

    I'm trying to set up something I've seen others asking: specifically, if a message is sent to "user@mydomain.com" (eg user123@mydomain.com) it will be forwarded to a single email address (eg inbox@mydomain.com). If mail is received at any other email address, it is replied to with "user not found". I have a Default address set up to reply with a "user not found" message. I also have a Global filter set up. I've tested the filter using the test process within cPanel and it works as expected. However, when sending messages from an external source, my filter isn't working. All messages are returned with "user not found" despite being sent to a valid email address like "user123@mydomain.com" that should result in forwarding. So my messages are being processed by my Default action, even though they should have been processed by my global filter. My understanding from the response in this thread, it that messages are processed by the global filters first, and if that doesn't result in any action, the default address action is taken. Is my understanding correct, and if so, why aren't my global filters working? Filter is as follows: To begins with user Action redirect to email inbox@mydomain.com Stop processing rules. I'm an end user of cPanel. Thanks for your help.
    0
  • cPanelLauren
    Can you show me the filter text you've set specifically? If you've set up a global filter it'll be located at /etc/vfilters/domain.tld
    0

Please sign in to leave a comment.