Setting up a personal email server. The computer that will serve as mail server is called 'neptune' and have the intern ip '192.168.0.3'. All other computer names or ip's are clients of the same network.
# Needed stuff (or recommended)
* fetmail - To fetch the email.
* procmail - Filter mail and split it eventually in differents mail boxes. [http://www.debian-administration.org/articles/242](http://www.debian-administration.org/articles/242)
* courier - mail server
* spamassasin - Filter mail, remove spam
* qmail
* MTA - Mail Transfert Agent
* Pyzor
* SpamBayes
# Some resources:
* [http://www.debian-administration.org/articles/323](http://www.debian-administration.org/articles/323)
* [http://www.linuks.mine.nu/debian-faq-wiki/MailQuestions](http://www.linuks.mine.nu/debian-faq-wiki/MailQuestions)
* See the courier website [http://www.courier-mta.org/](http://www.courier-mta.org/)
* [http://wooledge.org/~greg/mail.html](http://wooledge.org/~greg/mail.html)
* [http://www.hurring.com/howto/debian_mail_server/](http://www.hurring.com/howto/debian_mail_server/)
* [http://www.ma.utexas.edu/users/stirling/computergeek/email.html]() (very interesting)
* [http://www.firstpr.com.au/web-mail/RH90-Postfix-Courier-Maildrop-IMAP/](http://www.firstpr.com.au/web-mail/RH90-Postfix-Courier-Maildrop-IMAP/)
* [http://koivi.com/exim4-config/](http://koivi.com/exim4-config/)
* /usr/share/doc/mutt/html/index.html
* [http://www.dcs.gla.ac.uk/~lativyn/articles/debian-mutt/](http://www.dcs.gla.ac.uk/~lativyn/articles/debian-mutt/)
* [http://talk.trekweb.com/~jasonb/articles/exim_maildir_imap.shtml](http://talk.trekweb.com/~jasonb/articles/exim_maildir_imap.shtml)
* A complete different setup - [http://www.howtoforge.com/virtual_postfix_mysql_quota_courier](http://www.howtoforge.com/virtual_postfix_mysql_quota_courier)
# Setup:
I have follow the instructions of [http://www.hurring.com/howto/debian_mail_server/](http://www.hurring.com/howto/debian_mail_server/)
Make a domain name `/etc/hostnames` and `/etc/hosts`.
## Server Side:
# /etc/hostname
neptune.pinguin
# /etc/hosts
...
192.168.0.3 neptune.pinguin neptune
...
### Installing configuring exim4:
The config file of exim4 was splitted in several little files. Exim was already installed, if it's not install it with `aptitude install exim4` and select to make only one big configuration file. Otherwise it's to many annouying. If it's already installed:
dpkg-reconfigure exim4-config
And select to make one big configuration file.
For the type of mail configuration:
mail sent by smarthost; received via SMTP or fetchmail
Note: Previously i used the local delivery only; not on a network.
Delivery method for local mail:
Maildir format in home directory
Note: before i used the `mbox` format in `/var/mail/`.
We should now need to make an `~/Maildir` for each user on the server. It's important to make it because otherwise courier are go to complain. It's easier to add some stuff in the `/etc/skel/`, where all the default files are stored and used when us create a new user account on the system:
maildirmake /etc/skel/Maildir
If you have already made some users and not want to remove these use:
maildirmake ~/Maildir
The `maildirmake` have made the `~/Maildir` or the `/etc/skel/Maildir` directory with some sub-dirs.
### Installing and configuring courier:
aptitude install courier-imap courier-imap-ssl
Then reply to the questions that are asked:
* Faut-il créer les répertoires nécessaires à l'administration web ? - Yes
Tweaking the `/etc/exim.conf` file if the config file is not splitted in several little ones.
**Like there are some troubles to split the config file (dpkg-reconfigure exim4-conf not split the config file also when i tell him to do it :-s).**
Edit `transport/30_exim4-config_mail_spool`.
Note, i have not change some stuff in these config files.
Create a `~/Maildir` directory if it not yet exist. (But that should be automagically created when you send the first mail to the user in question)
In `/etc/email-addresses` define the outgoing email addresse name. Needed if you want to send to the outside world. I have append the following, just below all the commented stuff:
david: david.van.mosselbeen@telenet.be
yasmina: yasmina.el.ouaar@telenet.be
Test the stuff and send a mail:
# mail -s "test message" david
Look now in the `~/Maildir/new` of the user to who you have send the mail to see if the new mail is been there.
We now need to setup mutt, take a look at `/usr/share/doc/mutt/html/index.html`. Like probably these not go to see your mail.
Test the connection to see if it's been working:
telnet 192.168.0.3 imap2
To quit the telnet session, type:
zzzz logout
### Installing and configuring fetchmail:
Install fetchmail:
aptitude install fetchmail
Then i have add the following to the `~/.fetchmailrc` config file:
# Configuration created Sat Jan 28 08:36:11 2006 by fetchmailconf
set postmaster "david"
set bouncemail
set no spambounce
set properties ""
poll mail.telenet.be with proto POP3 user
'<my_isp_userid>' password '<my_isp_password>',
is 'david' here
mda "/usr/bin/procmail";
Testing the stuff with:
fetchmail -kv
Now let cron fetch your mail every 15 minutes. As a normal user `crontab -e` to edit your cron job file:
# For fetchmail
08,23,38,53 * * * * /usr/bin/fetchmail --syslog > /dev/null
# Try to send an mail:
neptune:/etc/exim4/conf.d/transport# exim4 -v david.van.mosselbeen@telenet.be
From: david@neptune.pinguin
To: david.van.mosselbeen@telenet.be
Subject: Testing exim
Testing exim
.
.
LOG: MAIN
<= root@neptune.pinguin U=root P=local S=423
neptune:/etc/exim4/conf.d/transport# delivering 1H7hOq-00038Y-5m
R: smarthost for david.van.mosselbeen@telenet.be
LOG: host_lookup_failed MAIN
no IP address found for host mail.neptune.pinguin
LOG: MAIN
== david.van.mosselbeen@telenet.be R=smarthost defer (-1): lookup of host "mail.neptune.pinguin" failed in smarthost router
## Client side:
dpkg-reconfigure exim4-config
And reply to the questions; here's what i have answered:
> Q: Split configuration into small files?
> A: No
> Q: General type of mail configuration
> A: mail sent by smarthost; received via SMTP or fetchmail
> Q: System mail name:
> A: venus.pinguin
> Q: IP-addresses to listen on for incoming SMTP connections:
> A: Empty (default 127.0.0.1)
Note, on the gateway computer, i only listen to the local ip (127.0.0.1), like there are 2 network cards! To avoid noise with the isp and the bastards. Gateway server is not yet the mail server too.
> Q: Other destinations for which mail is accepted:
> A: venus.pinguin
> Q: Machines to relay mail for:
> A: venus.pinguin
> Q: IP address or host name of the outgoing smarthost:
> A: neptune.pinguin
> Q: Hide local mail name in outgoing mail?
> A: No
> Q: Keep number of DNS-queries minimal (Dial-on-Demand)?
> A: No
> Q: Delivery method for local mail:
> A: Maildir format in home directory
Okay, we are done;
In `/etc/email-addresses` define the outgoing email addresse name. Needed if you want to send to the outside world. I have append the following, just below all the commented stuff:
david: david.van.mosselbeen@telenet.be
yasmina: yasmina.el.ouaar@telenet.be
For each use we want to provide mail. We should manually need to creat the `~/Maildir` and change the permissions so that it is only readable be the owner.
mkdir ~/Maildir
chmod go-rxw Maildir/
It should be look this way, if your not yet sure `drwx------ 2 foo foo 4,0K 2007-01-19 23:22 Maildir`.
Now we need to configure a email client. I use `evolution` as client.
Start `evolution` and go `Edit > Preferences` and add an new a email account. As email address i have write `david@neptune.pinguin`. To receive email, select `IMAP` (Not IMAPv4rev!) and as server, enter the ip of the mail server (192.168.0.3). The username should be the same as an user account on the mail server. (so you should maybe need to make some users on the mail server, see `adduser`). No encryption are used to receive the mail. To send mail, i have select the server type `sendmail`.
## Configuring procmail
This is optional. Not needed but probably useful if you want to do somethings with the mail when you get it. Especially when you get many mail to filter, move to another mailbox, or in a subdir of your INBOX, ...
In `/usr/share/doc/procmail/README.Maildir` i have find little bit usefull informations. Like i make use of Maildir.
Take the [procmailrc.example](http://spamassassin.org/dist/procmailrc.example) of spamassins website.
# squirrelmail (Webmail for nuts):
If you want a web interface to access your email. See [http://www.squirrelmail.org/](http://www.squirrelmail.org/)
aptitude install squirrelmail
Once installed, maybe restart the apache server `/etc/init.d/apache restart` and squirrelmail should work out of the box, yeah out of the box!
Fire up an web browser and point it to `http://localhost/squirrelmail/` and fill in your username and password.
Take a look to the config files located in `/etc/squirrelmail/` and fine tune it to your needs.
# Additional tips:
## Exim4:
Check where the mail goes to:
# /usr/sbin/exim -bt david@localhost.localdomain
That output:
R: system_aliases for david@localhost.localdomain
R: userforward for david@localhost.localdomain
R: procmail for david@localhost.localdomain
R: maildrop for david@localhost.localdomain
R: local_user for david@localhost.localdomain
david@localhost.localdomain
router = local_user, transport = mail_spool
With the `root` email address:
# /usr/sbin/exim -bt root@localhost.localdomain
That output:
R: system_aliases for root@localhost.localdomain
R: system_aliases for david@localhost.localdomain
R: userforward for david@localhost.localdomain
R: procmail for david@localhost.localdomain
R: maildrop for david@localhost.localdomain
R: local_user for david@localhost.localdomain
david@localhost.localdomain
<-- root@localhost.localdomain
router = local_user, transport = mail_spool
# Email clients:
* evolution (gui)
* thunderbird (gui)
* mutt (cli)