How to restrict a client to send mails only to particular domains

Latest response

Hi All,

I have sendmail installed on my RHEL 6.3 server.
I want to restrict it to send mail to only few domains(eg: la.calif.com ,lv.calif.com), so that mail to all other domains should not be good out.

Please Advice.

Responses

It's a lot easier to configure Sendmail to blacklist specific domains rather than whitelisting specific domains. Conceivably, you could use a mailertable configured with enumeration of your whitelisted domains, pointing them to a specific upstream relay and finish the table with a wildcard rule that discarded any messages sent not to those domains.

Hi All,

I configured the sendmail as below to restrict the mails to only one domain from my host.

[root@Test ~]# cat /etc/mail/mailertable
ak.test.com smtp:[mailhost.test.net]
. error:513

#

mailhost.test.net is our smtp relay server.


Still when I am able to send mail to gmail.com or yahoo.com which I dont want to happen. Can someone please help.

Not sure that a LHS token of "." will expand as expected (might want to try "*"). Other than that, I'm at a loss (safe to assume you restarted sendmail after enabling the mailertable?). Last thing I can suggest is force all email to relay through a smart-host, then configure that smart-host to only relay for your target domains (well-behaved MTAs have to be explicitly configured to relay - Sendmail's been that way since at least early in 8.9).

Postfix (the EL6 default), provides a lot more (easy) configuration options that could be leveraged. You've a number of options for configuring smtpd_client rules with Postfix.

If you can't solve it within your MTA, you could always solve it in iptables (basically set default-deny rule for ports 25, 465 and 587 preceded with allow rules for the domains you want to allow).

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.