All Linux distributions come with a Mail Transfer Agent (the program that does the routing and sending of the messages. The daddy of them all is sendmail (http://www.sendmail.org/).
sendmail is usually preconfigured, but if you need to set up a special situation (for example UUCP), it can become quite a nuisance. The reason for this is that at the initial writing of sendmail the configuration language was designed to parse quickly at the expense of being cryptic. I looked at a sendmail.cf in 1987 and didn't look again for 10 years.
smail is easier to understand and has always had the nice feature of batching messages, running the batches through gzip and sending the jobs off via UUCP. Saved me quite a lot of money in phone bills over the years.
However, a year and a half ago I found a package called BSMTP (Batched Simple Mail Transport Protocol) for taking care of the batch-gzipping stuff. BSMTP is a package which is used with UUCP. sendmail uses the SMTP Protocol if sending or reeiving mail via TCP/IP, but you can also feed mail into sendmail directly using this protocol. Now this package will take outgoing mail, put many messages in batches with SMTP commands inserted between messages, gzip the batches and hand them to UUCP for transport. On the other end the process is reversed, uucp receives, hands to an uncompressor which feeds to sendmail. This results in a compression of better then half. Using advanced features of the uucp on Linux you can achieve very high throughputs. BSMTP works with both smail and sendmail and has a macro package which makes sendmail configuration much easier. I like to tinker so I tried it. It took about a weekend to get sendmail working with BSMTP/UUCP. Once I had figured out the basics, it became much easier, I only needed about an hour to set it up for my leased line.
Since you have Linux, you have all the tools required. If not, install them from your distribution. I'll assume you have a working DNS with MX entries for our system and are connected by a leased line. Install the latest sendmail and sendmail-cf RPMs in the /usr/lib/sendmail-cf directory.
Consider the following few lines in a file called linux.mc located in /usr/lib/sendmail-cf/cf:
divert(-1) OSTYPE(linux) FEATURE(use_cw_file) define(`confCW_FILE', `-o /etc/sendmail/sendmail.cw') FEATURE(mailertable,`hash -o /etc/sendmail/mailertable.db') FEATURE(local_procmail) define(`STATUS_FILE',`/etc/sendmail/sendmail.st') MAILER(procmail) MAILER(smtp)It's rather cryptic--or is it?
Run this file through the m4 command by typing:
m4 ../m4/cf.m4 linux.mc > sendmail.cfIt produces a sendmail.cf of approximately 1200 lines (still unreadeable to me) which has been in production use on my system.
Now let's have a look at what those lines mean.
# divert(-1)This line is a directive to the macro processor which I have never bothered to understand. It has something to do with suppressing newline characters.
OSTYPE(linux)Now, that's fairly easy, right? Well, what it doesn't tell you is that the local delivery program mail.local from the sendmail distribution needs to be in /bin or your mail will disappear without a trace.
FEATURE(use_cw_file) define(`confCW_FILE', `-o /etc/sendmail/sendmail.cw')What on earth is a CW file?
I receive a lot of mail to the address of email@example.com; however, the host name is linux.lisse.na. No problem, we have an appropriate MX entry pointing lisse.na to linux.lisse.na, right? Wrong. You must tell sendmail the names under which it can receive mail on the local host. For example:
lisse lisse.na linux linux.lisse.naWhen doing this is overlooked, sendmail sends an error message which is somewhat misleading. The bouncing message has the following Subject: line:
Subject: Returned mail: Local configuration errorAnd the MX list line is what is confusing:
----- Transcript of session follows ----- 554 MX list for nws.com.na. points back to linux.lisse.na 554 firstname.lastname@example.org... Local configuration error
FEATURE(mailertable,`hash -o /etc/sendmail/mailertable.db')This line is only required if you have special delivery situations. For example, to use the BSMTP package to deliver mail for Triple A, Inc. via the UUCP neighbour bbbbb, set up an MX entry in the DNS and write something like this in the mailertable file:
.aaa.com.na bsmtp:bbbbb aaa.com.na bsmtp:bbbbbA TAB character is in between the pairs, and you must run a program from the sendmail package called makemap on the file mailertable to produce the binary database file mailertable.db. For example:
makemap hash < mailertable mailertableThere are other database systems (for example, dbm) but let's not complicate matters.
FEATURE(local_procmail)This line redefines the local mailer to be procmail. You most definitely want that.
define(`STATUS_FILE',`/etc/sendmail/sendmail.st')This line defines the status file. Make sure you have created this directory as root.
MAILER(procmail)procmail was written by Stefan van der Berg at my alma mater and deserves its own article. In short it is the local delivery program. Its strength lies in its message filtering capabilities. Very nice for those mailing lists.
MAILER(smtp)Please note that I have left out the bsmtp entry that would be required, if you had used a BSMTP entry in the mailer table. If you had a UUCP neighbour, you'd need a mailer entry too which must come after smtp.
Now, test this configruation file, copy it to the /etc directory after making a backup copy of the old one and restart sendmail. As root, I use the command:
killall -HUP sendmailI did not show you how to set up sendmail for UUCP, BSMTP, anti-SPAM or virtual domains. However, now that you have mastered the basics, it will be fairly easy.