Configuring Home Email on Linux

Linux systems generally have typical Unix mail. On most systems, sendmail is used the Mail Transfer Agent. Mail is stored in a file /var/spool/mail/$LOGNAME.

This system works great for a normal Internet-connected machine, with real DNS and a static IP address, but for dial-up systems, a few changes need to be made.


Sendmail

Sendmail can be easily configured to put valid headers on your outgoing mail. The simplest way to configure it is to edit /etc/sendmail.cf and find the DM line. You'll probably see something like this:

# who I masquerade as (null for no masquerading) (see also $=M)
DM
Simply change that to this:
# who I masquerade as (null for no masquerading) (see also $=M)
DMluci.org
if you want your mail to appear to be from your username@luci.org.

Please note that directly editing sendmail.cf is normally not the best way to configure sendmail. For anything more complicated than this, you'd definitely want to go through generating sendmail.cf with m4 as usual.


Procmail

Procmail is a local Mail Delivery Agent. It is also great for automatic mail filtering and sorting. On systems where procmail is the system MDA, such as Red Hat Linux, all you have to do to set up filtering is create a .procmailrc in your home directory.

The format of the .procmailrc is quite simple. First you can define variables used by the program. For example, in my .procmailrc I have the following lines:

MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/log
MAILDIR is the default directory where procmail stores files you specify as targets in recipies. Procmail logs all mail delivery in the file specified by LOGFILE. The format of the log file looks like this:
From steve  Mon Aug 24 17:45:23 1998
 Subject: LUCI: Tuesday, August 25 meeting
  Folder: /var/spool/mail/steve                                            2185

Recipies, procmail's filters, look like this:

:0
* ^TOfriend@public\.com
/dev/null
That example will send any email to the address "friend@public.com" (an address spammers seem to love sending to) straight to the bit bucket. The first line simply marks the beginning of a recipie. It can also contain optional flags to search just headers (the default), just the body, or both, plus a few other things. The second line starts with "", then contains a case-insensitive regular expression. ^TO is short for
(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)
(There are other similar "magic" tokens.)

Procmail's many features are documented quite well in the procmail(1), procmailex(5), procmailrc(5), and procmailsc man pages.


Fetchmail

Fetchmail is a general purpose POP-3 and IMAP client. It can be used to pull mail off of a mail server and introduce it into the local spool. It can run as a daemon (with -d n, where n is the number of seconds to delay between fetches. It can be configured with the file .fetchmailrc in your home directory.

For example, let's say your mail server is mail.server.net, your username on that server is larry, and your password is "Perl". If you wanted to pull your mail every 10 minutes, you'd start fetchmail with fetchmail -ad 600, and you'd want something like this in ~/.fetchmailrc:

poll mail.example.net proto pop3 user larry pass Perl mda "/usr/bin/procmail -f -"


Steven Pritchard
steve@silug.org