The aim of this short report is to help Linux users to configure their email system in a multi-user environment. Let's say that you have a PC in your house, that you access Internet with a modem and that you want to provide a email address to everyone in your family : this help is for you !
Maybe it is not so difficult to configure sendmail ... for a Linux freaks, but for the others, a starting point will certainly be appreciated. I think that Internet connection and email configuration is the basic functionality that a PC must satisfy.
This introduction provide the typical 'case' of somebody connecting to Internet with a modem (not permanently connected) through an Internet provider. This typical user have only access to one mailbox (the case of multiple mailbox is simpler) which he wishes to split in multiple mailboxes on his local computer. Since the typical user could frequently change of Internet provider and since he likes to keep only one email address, he use aliases which are only a 'redirection' from a email address to an other. Each local user have a different alias name on the alias server and that is based on this alias name that the local computer can redistribute the mail coming from a unique mailbox to different local mailboxes.
It's also very interesting to be able to write email's off-line. Once online, the mail of all the users are sent and the the mail for everyone is fetched. In one pass ... Think on your telephone bill.
Suppose that you have only two users on your local PC, let's say Paul Dupont and Luc Jackson. The former has the login 'paul' and the last has the the login 'luc'. Through your local Internet provider, you have access to a POP3 mailbox. Your address for this mailbox is 'email@example.com'. Luc and Paul have subscribed an alias address, respectively Luc.Jackson@advalvas.be and Paul.Dupont@advalvas.be. These aliases forward any received mail to your mailbox 'firstname.lastname@example.org'.
On the local PC, Luc and Paul have respectively the local addresses 'email@example.com' and 'firstname.lastname@example.org' where 'linuxpc' is the name you have chosen for your computer. Luc and Paul wish to read their mail with Netscape, through a local POP3 server. As they send a mail to an Internet address, they wish to be able to send this mail off-line. They also wish that the address that the recipient will see doesn't contain the name of your local computer (linuxpc) but well the name of the alias server domain (advalvas.be). So, if luc send a mail to 'email@example.com', 'somebody' will think that the mail come from 'firstname.lastname@example.org'.
This situation is illustrated in the following figure.
To build the sendmail configuration file, it is highly suggested to use the m4 tool. In the directory /usr/lib/sendmail-cf/cf, create a file .mc. For example, my file /usr/lib/sendmail-cf/cf/linuxpc.mc contains the following :
||Begin of a comment text|
More information about the m4 configuration file at http://www.sendmail.org/m4/index.html
For each 'generic host' (such as defined in /usr/lib/sendmail-cf/cf/linuxpc.mc),
the user name (and optionally the domain name) of the sender is changed.
The table contained in /etc/mail/genericstable describe which changes has to happen.
In order to create the database file /etc/mail/genericstable.db, one should type the following :
makemap hash /etc/mail/genericstable.db < /etc/mail/genericstable
Optionally, you may change the alias file. In this way, you could, for example, send a mail to 'paul.dupont' locally (without domain name) and this mail would be directly delivered to 'paul'. So, add the following line on the end of /etc/aliases
After doing this, you have to rebuild the alias database. Type
This is the file containing names of hosts for which we receive email. In our example,
As user root, type
killall -HUP sendmail
If you want that every user is able to send the mail queue, you have to set the user ID on execution.
chmod a+s /usr/sbin/sendmail
The POP2 and POP3 server daemon are name ipop2d and ipop3d, respectively.
In the Redhat distribution, they are included in the package imap.
You can check if this package is installed :
rpm -q imap
If not, look for a file named imap*.rpm on the installation CDROM and install it with
rpm -ivh imap*.rpm
the inetd daemon is responsible for listening on the TCP/IP port and to start the appropriate daemon (dependent on the port number) when a connection is established. For example, the pop-3 service use the port 110. Every time one try to connect to the pop-3 service (on port 110), inetd will start ipop3d. In /etc/inetd.conf, be sure that the following lines are presents and uncommented :
pop-2 stream tcp nowait root /usr/sbin/tcpd ipop2d
pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d
The files /etc/hosts.allow and /etc/hosts.deny describe which hosts are allowed to use the local INET services. If you want that only the local host be able to access this service, set the following :
You have to make sure that the services pop-2 and pop-3 are defined. Check in /etc/services that the following lines are presents :
pop-2 109/tcp postoffice
It make the association between a service name (i.e. pop-3) and a service number (i.e. 110).
To restart inetd, type
killall -HUP inetd
fetchmail fetches the mail on a POP3 server and redistribute the mail locally via sendmail. Each user (who must be able to fetch the mail for everybody) must have a configuration file .fetchmailrc in his home directory. In our example, it looks like this :
poll pophost.provider.com with protocol POP3 aka advalvas.be no dns :
user dfzt12 fetchall with password kdwMlp45 to Paul.Dupont=paul Luc.Jackson=luc
The 'aka' is only used for multi-drop. In this example, it declares a DNS alias for 'provider.com'. If you look at the fetchmail man page, you will read :
When fetchmail, while processing a multi-drop mailbox, grovels through message headers looking for names of the mailserver, pre-declaring common ones can save it from having to do DNS lookups.
The option 'no dns' prevents the multi-drop system from looking for domain name aliases (for each recipient). If this option wouldn't be specified, it should be possible that a mail cannot be fetched because one of the recipient has an invalid domain name.
The option 'fetchall' ensures that all messages are fetched even the message that you have already read.
fetchmail won't work if the configuration file hasn't the appropriate permission.
chmod 0710 .fetchmailrc
To fetch the mail and to redistribute it, a user can type
To send the mail queue, type
To check the mail queue, type