Everyone knows that Sendmail is huge and scary. But if someone explains you in details, you figure out you can master it.
I don't work heavily with Sendmail, although I may in future. So I write this article that can help me if I need to remind myself with some details about Sendmail (hence this is more theoretical article with some examples on Solaris).
Most companies nowadays use Microsoft Exchange (for storing users' emails), but Sendmail is still present as relay between Exchanges. There are tons of ways how this is implemented, like inbound and outbound relays, etc, etc.
Sendmail can work as MTA and MSP. For each of them Sendmail uses separate configuration files and command line options.
Here are sendmail processes on the test machine.
> ps -ef | grep sendmail root 4236 29935 0 08:54:37 pts/2 0:00 grep sendmail smmsp 367 1 0 Sep 30 ? 0:03 /usr/lib/sendmail -Ac -q15m root 362 1 0 Sep 30 ? 0:49 /usr/lib/sendmail -bd -q15m |
I look at line with arguments "-bd -q15m". Things that tell me this is MTA process:
The default configuration file for MTA is sendmail.cf (say the location may be in the directory /etc/mail/cf/cf/)
Other files MTA is using are:
So basically, when incoming email hits MTA, MTA think about it in 2 ways:
> ps -ef | grep sendmail root 4236 29935 0 08:54:37 pts/2 0:00 grep sendmail smmsp 367 1 0 Sep 30 ? 0:03 /usr/lib/sendmail -Ac -q15m root 362 1 0 Sep 30 ? 0:49 /usr/lib/sendmail -bd -q15m |
I look at line with arguments "-Ac -q15m". Things that tell me this is MSP process:
The default configuration file for MSP is submit.cf (say the location may be in the directory /etc/mail/cf/cf/)
The MSP and MTA is most likely same machine, but MTA can be different one. Define MTA (for MSP) in the file submit.cf (see line like D{MTAHost}[127.0.0.1] )
None nowadays is editing (sendmail|submit).cf file. Folks use macros to create .mc file and then run them through m4 program in order to create .cf file.
Maybe like:
m4 example.mc > example.cf cp example.cf sendmail.cf |
The file /etc/mail/local-host-names has list of hosts/domains that are local for MTA. This file used to be called sendmail.cw. It's good it has been renamed; I guess people confuse this one with sendmail.cf. So in order to use the file local-host-names, the feature use_cw_file is needed (now you know origin of this feature).
FEATURE(`use_cw_file') |
There are two situations here:
The mailertable file is database where you associate remote domain with physical (or virtual) machine, where email has to be forwarded. Hence the FEATURE(`mailertable') is needed.
So if MTA gets email for user1@etcfstab.com, it will forward it to machine matteo.lazyhunter.com (using SMTP). The mailertable file should has the line :
googlyx.com smtp:matteo.lazyhunter.com |
Do not forget to create 'hash' type database from this text file.
makemap hash mailertable < mailertable |
This is usually used when company acquires another company but still uses acquired domain to receive emails. In above example, Lazyhunter acquired Googlux and accepts emails to the Googlux domain but sends them to email server in Lazyhunter domain.
RelaysBut what if acquired company is not integrated and still uses its own email server. In this case, we can relay emails to this server. The file relay-domains should have:
etcfstab.com |
So now, email sent to user1@etcfstab.com will be relayed (by Lazyhunter email server) to email server responsible for etcfstab domain.
But relay-domains file is also used for outgoing relaying. If I add line ..
10.10.10 |
.. this means that machines from this internal network are allowed to use our Sendmail to relay messages that are going out (to the Internet).