Restrict outgoing email to certain domains
Hi, I'm trying to restrict emails from my account (mydomain.com) and only allow users email addresses at mydomain.com and myotherdomain.com, with the exception of users john and david ..
I've tried the code below with no luck, all emails fail !?
I'm new to this and this is my first attempt so I apologise if I'm way off !
Any help would be appreciated, thanks.
if first_delivery
and ("$h_from:" contains "@mydomain.com")
and ("$h_from:" does not contain "john@mydomain.com" or "$h_from:" does not contain "david@mydomain.com")
and ("$h_to:, $h_cc:" does not contain "@mydomain.com" or "$h_to:, $h_cc:" does not contain "@myotherdomain.com")
then
fail "Cannot send to this recipient."
endif-
Hello, Can you confirm if you are attempting to filter outgoing email (e.g. mail sent FROM the cPanel server), incoming email, or both? What method did you use to setup the filter? Thank you. 0 -
Hi, thanks for the reply. I'm trying to restrict outgoing email to be limited to sending to certain domains. I put the filter file above in /etc/cpanel_exim_customfilter and then pointed the 'system filter file' setting at this within the Exim Configuration Manager on WHM. Is there an easier way to achieve this ? Thanks again. 0 -
Hello, A custom Exim system filter rule is the correct approach when attempting to block outgoing email. Here are some threads with examples you may want to use when developing and testing your own custom rules: Also, in "WHM >> Exim Configuration Manager", under the "Filters" tab, are you using a custom filter for the "System Filter File" option? If so, you'd need to add your custom filter rules to that custom system filter file itself instead of adding them as separate filter files under the options directory. There's a thread on this topic at: 0 -
Yes I'm using a custom system filter file with my rules and have that file specified in the "System Filter File" option. Thanks, I'll have a look at those threads. 0
Please sign in to leave a comment.
Comments
4 comments