NSLU2

tech
top
Index
1 Introduction
2 Installation
3 DNS/DHCP server
4 Installation of Apache
5 An NFS server
6 Installing a mailserver
7 Alternatives
8 Sane remote scanner
9 problems
\"cover\"

Previous: 5. An NFS server Index Next: 7. Alternatives

6. Installing a mailserver

One of my nslu2s is going to be a mailserver. That is not a simple task. If you look at all the mail programs and their configuration, it seems that anyone creating them has a severe psygological disorder.

I tried different howto's but none of them seems to work. The list of failed howto;'s are:
http://www.nslu2-linux.org/wiki/OpenSlug/MailServer http://lika.be/wp/2005/08/setting-up-the-nslu2-as-mail-server http://www.nslu2-linux.org/wiki/HowTo/SetUpAnEmailServer http://www.nslu2-linux.org/wiki/HowTo/SetUpAnEmailServer2 http://www.nslu2-linux.org/wiki/HowTo/QMailOnTheNSLU2 http://lena.franken.de/linux/debian_and_vserver/sendmail.html http://www.aboutdebian.com/internet.htm

All seem to work up to a point, but most leave your slug is such a state that you need to reinstall.

They provide, however, some insight in what kind of configuration is needed First I installed the software:
apt-get install sendmail sendmail-bin uw-imapd uw-imapd-ssl mailx

This suggests to install uw-mailutils sendmail-doc sasl2-bin libsasl2-modules libsasl2-modules-plain libsasl2-digestmd5-plain libsasl2-digestmd5-des cyrus-common logcheck mutt and imap-client. It also asks whether you want to continue without maildir support. We'll continue without (anwer Yes). Check that following entries exist in /etc/services file.
     imaps		993/tcp
     pop3s		995/tcp

Add the following entries in /etc/inetd.conf :
     pop3s	stream	tcp	nowait	root	/opt/sbin/ipop3d	ipop3d
     imaps	stream	tcp	nowait	root	/opt/sbin/imapd	imapd

Run newaliases.

Now, connecting to phaedrus works. I used Thunderbird and connected through ssl/tls. It complains about an unsigned certificate. That is ok for me, because I am only on a small home-network.

AFter a while, your certificate will expire. Mail clients will comlpain and for your non-technical faniliy members, panic will break out. Simply regenerate the certificate with:
openssl req -new -x509 -nodes -days 365 \
-out /etc/ssl/certs/imapd.pem \
-keyout /etc/ssl/certs/imapd.pem

When it asks for a
Common Name (eg, YOUR name) []:

answer with the fully qualified hostname of your IMAP-server, phaedrus.home in my case.

But there is only a single empty inbox in the account. So let's send some mail:
phaedrus:/usr/local/bin# telnet 127.0.0.1 smtp
helo there
mail from: napoleon@elba.fr
rcpt to: ljm@phaedrus.home
data
Alons enfants de la patri-i-e..
.
quit

Trying to get mail now from Phaedrus hangs. Thunderbird seems to take ages to open the inbox. From the log, there is a complaint about a lost lock.

That means some additional configuration will be required. First the sendmail.mc:
include(/usr/share/sendmail/cf/m4/cf.m4)
VERSIONID(`sendmail.mc - ljm 200906031210')
OSTYPE(linux)dnl
define(`SMART_HOST',`smtp.xs4all.nl')dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(`always_add_domain')dnl
FEATURE(`local_procmail', `/usr/bin/procmail')dnl
FEATURE(`genericstable', `hash -o /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN(`localhost pheadrus.home')dnl
MAILER(local)dnl
MAILER(smtp)dnl
LOCAL_CONFIG
Cw localhost pheadrus.home
VERSIONID should be optional, but it is good to include it anyway
OSTYPE includes a set of defaults for the Linux OS. 
FEATURE calls a set of predefined macros
MAILER gives the possible mail deliveries
dnl is just a list option

And pass it through m4:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

I need the masquerade_envelope and genericstable, because I need to rewrite my originator address. Well, I might, if I decide that all outgoing mail needs to go through my mailserver, perhaps, one day,...

Restart sendmail:
/etc/init.d/sendmail restart

Make sure that the spool directories are accessible for all mail recepients. If you're not too concerned about security, make the spool directory permissions 1777. And resend the mail from Napoleon. And then:
ljm@phaedrus:~$ mail
Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/ljm": 3 messages 3 new
>N  1 napoleon@elba.fr   Tue Jun  2 20:34   12/435
p
Message 1:
From napoleon@elba.fr  Tue Jun  2 20:34:54 2009
Date: Tue, 2 Jun 2009 20:32:27 +0200
From: napoleon@elba.fr
To: undisclosed-recipients:;
Alons enfants de la patri-i-e..

Next is the IMAP. For some reason, it now works without additional configuration. Make sure that your mail client uses SSL!

Next is fetchmail.
apt-get install fetchmail

To be honest, I want to run this mail server a little while in parallel to my current server. So I made an extra mailbox at my provider for testing purposes. Let's say the mailbox is called testmail.

In the home-directory of root I made a file .fetchmailrc with the following contents:
poll pop.xs4all.nl with proto POP3
        user "testmail", with password "ZeEr GeHeIM", is ljm here warnings 3600

Because there are passwords in the file, chmod 600 .fetchmailrc. Fetchmail won't run otherwise. And start fetchmail:
phaedrus:~# fetchmail -v -v -v -v                                    
fetchmail: WARNING: Running as root is discouraged.                  
fetchmail: 6.3.6 querying pop.xs4all.nl (protocol POP3) at Wed Jun  3 19:26:50 2009: poll started
Trying to connect to 194.109.6.55/110...connected.                                               
fetchmail: POP3< +OK xs-pop3d (1.75 04-Dec-2008) at mailpop20.xs4all.nl starting
fetchmail: POP3> CAPA
fetchmail: POP3< +OK Kappa 10-4
fetchmail: POP3< TOP
fetchmail: POP3< USER
fetchmail: POP3< UIDL
fetchmail: POP3< LAST
fetchmail: POP3< RESP-CODES
fetchmail: POP3< .
fetchmail: pop.xs4all.nl: opportunistic upgrade to TLS failed, trying to continue.
fetchmail: POP3> USER testmail
fetchmail: POP3< +OK Password required for testmail.
fetchmail: POP3> PASS *
fetchmail: POP3< +OK testmail has 0 messages (0 octets)
fetchmail: selecting or re-polling default folder
fetchmail: POP3> STAT
fetchmail: POP3< +OK 0 0
fetchmail: No mail for testmail at pop.xs4all.nl
fetchmail: POP3> QUIT
fetchmail: POP3< +OK Updating mailbox - exit
fetchmail: 6.3.6 querying pop.xs4all.nl (protocol POP3) at Wed Jun  3 19:26:51 2009: poll completed
fetchmail: not swapping UID lists, no UIDs seen this query
fetchmail: Query status=1 (NOMAIL)
fetchmail: Deleting fetchids file.
fetchmail: normal termination, status 1
fetchmail: Deleting fetchids file.
phaedrus:~#

That went well, but there was no mail! So next send some mail and we're done.

Previous: 5. An NFS server Index Next: 7. Alternatives