[Home | Disclaimer | Previous | Content | Next | Contact me]

Mail

Our server provides sendmail running in daemon mode to send email locally or to the internet. Sendmail passes emails addressed to the internet by SMTP to the ISP’s mail server. Email addressed locally is passed directly into the user’s mailbox (/var/spool/mail/<user> ). Emails sent from Win clients are relayed by sendmail. For this reason the mail client used at Win side has the servers IP address configured as SMTP server.

Our server offers IMAP for Win clients to access their email. The emails are stored at our server in the user’s standard mailbox. Emails are fetched from ISP by fetchmail and put into the standard mailbox. This fetch is triggered periodically by cron.

Flow of emails

It is assumed that each user in our LAN has a corresponding linux user account at server side. Furthermore it is assumed that each user in our LAN has his own email address at ISP side. Our ISP’s domain is defined as bestisp.de. Replace it by your ISP’s real domain.

Example:

User’s real name
Karl Napf
Linux user name
knapf
ISP’s email address
Karl.Napf@bestisp.de

Mind that YAST2 will automatically add a mailbox for each user added.

Mailbox:        /var/spool/mail/knapf

Also mind that all the following configuration examples are referring to the sample user Karl Napf. So replace all Karl Napf related data to your actual user!

Setting up Win2000 clients

Due to the immense number of MS operating systems only Win2000 is considered. Due to the immense number of email clients only Outl2000 is considered. At client side we are using the ISP’s email address as sender address.

Mind that at client side we are configuring for a single user. That means that this user can access his internet email. So keep in mind that each Win user accessing email needs a linux user account on our server and needs an email address assigned from the ISP.

Outl2000 has to be configured as “working via internet” in contrast to “working with exchange server”. This is a general setting chosen when configuring Outl for the first time. When configured incorrectly you will not be able to choose IMAP client.

Email Services Settings

From Outl choose “Extras->Options” and the “Email Transfer” tab.

Email transfer settings

From there click button “Accounts” and the “Mail” tab in the dialog to pop up.
Add a new account with the “Add” button. Edit the properties with the “Properties” button

Choose the “General” tab there. Enter the user’s name and his ISP address as assigned from the ISP.

Email server general settings
 
Choose the “Servers” tab and enter our server as incoming and outgoing server. As “Account name” enter our server account name of the user. Password must be our server password of the user. Check the “Remember password” check box to not always be prompted for a password.

Email servers settings

Change to the “Connection” tab and make sure that “Connect using my local area network (LAN)” is checked.

Change to the “IMAP” tab and enter ~knapf/mail for the “Root folder path”. Please note that ~knapf is the IMAP notation for the root directory of user knapf on our server and must be changed to the actual username (by keeping ~ and adding user name). For the meaning of this setting read chapter Setting up imapd at server .

Email server imap settings

Setting up sendmail at server

As noted above our server does not have to map the sender address when sending email via internet (because we are using the ISP’s email address as sender address at client side). This is important as we have realized that mapping sender addresses leads to big confusions for receiving MS email clients because the email header is interpreted incorrectly! Of course our server must realize that emails sent to a “bestisp.de” account must be delivered locally as we do not want to route internal email traffic by internet.

For each email user added we have to modify a few configuration (e.g. /etc/mail/genericstable and /etc/aliases; see below). To ease this task we have written a script /sbin/addmailuser which is not in the state to be spread. For this script only /etc/.fetchmailrc is used as source. Other files are generated from the data provided there.

Providing complete /etc/hosts

To make sendmail work correctly we need a complete setup /etc/hosts file. That means every client sending and/or receiving emails must have an entry in /etc/hosts.

Extract from /etc/hosts:

192.168.0.2       ibw2.domain1     ibw2

Each client must be entered with it’s IP address and fully qualified host name and a short host name. Mind that domain1 is our internal domain name. Also mind that the name must be used for the “Full computer name” of the Win client which can be entered by choosing Properties of the “My Computer” icon of the desktop (tab “Network Identification”).

Setting SuSE environment variables

The file /etc/sendmail.cf is the main configuration file for sendmail. Using SuSE this file is generated according to variables which can be set by YAST2 “RC-Config Editor”. Alternatively you can check the setting of all related variables in /etc/rc.config.d/sendmail.rc.config and /etc/rc.config .

FROM_HEADER= "bestisp.de"
The domain of the “from” address of all outgoing emails is replaced by bestisp.de. Mind that even when using /etc/mail/genericstable for mapping user names this entry is mandatory! It triggers generation of mapping rules in /etc/sendmail.cf.

SMTP=”yes”
Start sendmail as daemon. We need a daemon running to relay emails from Win clients.

SENDMAIL_TYPE="yes"
Let SuSEconfig generate /etc/sendmail.cf. This is why we are setting all these environment variables. Otherwise they would have no effect on /etc/sendmail.cf.

SENDMAIL_SMARTHOST=”mail.bestisp.de”
Set the mail server of your ISP. You get this information from your ISP.

SENDMAIL_LOCALHOST="localhost ibw10 ibw10.domain1 bestisp.de"
These are the hosts considered as local. For these hosts emails are delivered locally (not passed to the ISP). We have set in the hostname of the linux server (ibw10) and the hostname of the linux server completed by our local domain name (ibw10.domain1) and our ISP’s domain name. The latter is needed because we want emails addressed to bestsip.de to be delivered locally. Think of an email send to Karl.Napf@bestsip.de from within our LAN. This email should be delivered locally without being routed through the internet.

SENDMAIL_RELAY=""
This has to be left empty as we want to deliver certain emails locally and not to relay all emails.

SENDMAIL_ARGS="-bd -q30m -om"
The arguments used when starting sendmail; –bd for starting in daemon mode; -q30m for flushing the outgoing mail queue every 30 minutes; -om stands for sending to the sender when the sender is one of the receivers, even when the receivers result from alias replacement.

SENDMAIL_EXPENSIVE="no"
This will send outgoing emails immediately. We do not want to flush the outgoing mail queue explicitly by sendmail -q. Disadvantage of this feature is that every time an email is delivered an ISDN connection is initiated on demand.

SENDMAIL_NOCANONIFY="yes"
Sendmail will not use DNS queries to canonify host names. Only rely on /etc/hosts.

SENDMAIL_NODNS="no"
This would disable any DNS access for sendmail. We have not set this option as the setting of  SENDMAIL_NOCANONIFY prevented any DNS queries for our example. The side effects of setting this variable are unknown.

SENDMAIL_DIALUP="no"
We left this variable at default. It should suppress any dialup triggered by sendmail. Well, we want a dialup to happen. The side effects of setting this variable are unknown.

SENDMAIL_GENERICS_DOMAIN=""
Entries of /etc/mail/genericstable may alter domains set with this variable. As we have no additional domains as the one set in FROM_HEADER we do not care about this setting.

MASQUERADE_DOMAINS=""
As we are only hosting a single domain we do not touch this setting.

/etc/mail/access

In order to relay emails originated from Win clients we have to add a line to /etc/mail/access.

192.168.0    RELAY

All messages originated from our LAN (host’s IP address starting with 192.168.0) are allowed for relay. Mind that this entry is mandatory. Otherwise no emails from the Win clients will be accepted.

/etc/mail/genericstable

The sender address (from address) must be replaced whenever local email addresses are passed to the internet. This happens for example when you are sending an email directly from our server. As mentioned above the Linux user knapf@ibw10.domain1 represents Karl.Napf@bestisp.de for the outside world. To enable this replacement add for each email user a line at the end of /etc/mail/genericstable.

knapf@ibw10.domain1        Karl.Napf@bestisp.de

/etc/aliases

We are also in need to replace receiver addresses when they are addressing a local account. E.g. emails addressed to Karl.Napf@bestisp.de and originated in LAN have to be mapped to knapf@ibw10.domain1. If this replacement would not take place the email would be relayed to the internet and finally be received again from the ISP. We want it to be delivered without this indirection. For each email user a line has to be added at the end of /etc/aliases .

Karl.Napf @bestisp.de:    knapf

Setting up fetchmail at server

The ISP is presenting email by POP3. On our server we let user root fetch mails for all participating email users from ISP by calling fetchmail . This fetch is triggered periodically by cron (see man cron on how to use). You have to execute crontab –e as user root.

0  7-19  *  *  1-5  /usr/bin/fetchmail  -a -v >>/var/log/fetchmail 2>&1 &

The above crontab line will execute fetchmail hourly for weekdays from 7:00 to 19:00. All fetchmail calls are logged into /var/log/fetchmail .

Cron is executing the above line as user root. For this reason we have to create /root/.fetchmailrc and add a line for each email user looking like:

poll pop.bestisp.de protocol POP3 user Karl.Napf password <karlnapfspasswd>  is knapf #Karl.Napf

poll pop.bestisp.de
POP3 server to fetch mail from

protocol POP3
using POP3 protocol

user Karl.Napf
username used at ISP side

password <karlnapfspasswd>
password for use at ISP side

is knapf
the associated linux user at our server side

#Karl.Napf
only a comment we use to generate other files from this file by script (not relevant to readers outside our office).

Setting up imapd at server

We have installed the cyrus imapd as it will not require additional configuration. It simply offers all users standard mailbox as INBOX.

In order to make imapd start as soon as client access happens we have to comment in a line in /etc/inetd.conf.

imap    stream    tcp    nowait    root    /usr/sbin/tcpd    imapd

By default you will find this line commented out.

Furthermore make sure that the SuSE variable START_INETD=”yes” so that inetd is started at boot up.

It is possible to create new folders with an IMAP client. This is good to move email messages from INBOX to another location for structuring or archiving. For this reason we are creating a mail directory in the home directory of each mail user ($HOME/mail).  See chapter Setting up Win2000 clients on how to configure this directory as users root folder path. Any new folders created by the client are created into this directory as “normal” files. Mails moved into those folders are put into the related files.

[Home | Disclaimer | Previous | Content | Next | Contact me]