Freebsd – Force sendmail to ignore local domain when sending mail (FreeBSD)

freebsdsendmail

I send mail using PHP. Everything works good until I send mail to domain (@example.com) which I have in /etc/rc.conf >> hostname="box.example.com".

I guess sendmail catches mail for this domain (even when I use its subdomain in rc.conf) before sending it to world. So, how can I make sendmail to ignore local domain(s) other than localhost?

Best Answer

This is a recurring question, but it is the first time I've seen it for FreeBSD. See this answer on how to edit your freebsd.mc file. Because the above link answers the question for Debian, here is what you need to do in FreeBSD:

# cd /etc/mail
# cp freebsd.mc box.example.com.mc
# vi box.example.mc (and follow the instructions of the link above)
# make all install restart

You can now test the solution.

Since you write that /etc/mail/local-host-names does not exist, run sendmail in test mode with sendmail -bt and then at the > prompt type $=w. This will list you all the names that sendmail considers local. You will see box.example.com in this list.