2

I would like to know how to configure sendmail to only send emails to one domain.

I have a development server that might have customer email addresses in the database as the data is copied from the production server from time to time. I would like to make sure that the developement box (Redhat 5.3) does not send any mails externally but will send to my local users. For the sake of argument my domain is example.com and sendmail is currently set to relay mail to our SBS2008 exchange server.

So far I have not been able to find out how to do this.

Wesley
  • 32,320
  • 9
  • 80
  • 116

1 Answers1

2

Try adding this in your sendmail.mc:

LOCAL_RULE_0
R$* < $=w . > $*     $#OK
R$* < $*. > $*       $: user < @ example.com. > $3

This modifies ruleset 0 (the one that selects how email is going to be routed) as follows: If this is a local mail address (the domain part is included in $=w) then proceed as usual. Else, send email for every external address to user@example.com.

When adding the above snippet in your sendmail.mc take care to NOT copy-paste the rules, but type them. The two sides of the rules are not space separated. They are separated by tabs (at least one; two or more do not make a difference).

After editing sendmail.mc you have to produce sendmail.cf and restart sendmail. I do not know how this is done in your distribution. In Debian I run sendmailconfig.

adamo
  • 6,867
  • 3
  • 29
  • 58