Sometimes SendMail behaviours are definitely strange.
Lately I moved my mail server from one machine to another, both running FreeBSD (6.0 the old one and 6.2 the new one) and both running DBMail as mail backend. Everything went smoothly… apart from the fact that just one domain wasn’t working.
Let’s step back a second. DBMail plugs into SendMail by using the mailertable standard. There you say that any mail for a specific domain has to be routed trough a different delivery service instead of the standard local one (SendMail‘s internal). Thus I have no users and domain configured in SendMail as everything gets forwarded to DBMail. This is easily done by adding the following code to /etc/mail/mailertable:
Pretty simple: if you receive mail for domain brancatelli.it forward it to dbmail as mail for domain brancatelli.it. Everything was working but one domain: brancatelli.it. Every time I tried to send any mail to email@example.com SendMail was trying to deliver mail locally (read: internally) and thus was reporting an “User unknown” error to the remote mail server.
To make a long story short the problem is that SendMail define a special class of domains called “Class L”. Domains in this class are treated as special local domains that override any other definition from mailertable or such. Now the funny thing is that SendMail‘s default behaviour is to include localhost’s FQDN in the Class L (actually it makes some sense) and to lookup in the DNS the corresponding MX records for this host (thus even if the localhost name was carota.brancatelli.it he considered brancatelli.it as a local domain because he was listed as the MX for that domain – a very interesting assumption, I’d say). To override this behaviour you can just create an empty /etc/mail/local-host-name (the file used to override the Class L definitions) and you’re done.
(there’s always a “but”)
Be careful! When I say “EMPTY” /etc/mail/local-host-name I really mean EMPTY. I mistakenly created the file by including a white line inside, and for some reason I really don’t know (and actually really don’t care about) SendMail probably assumed the file was garbled and ignored it.
It took me almost two days to find out that this was the problem, so pay real attention to it.