cancel
Showing results for 
Search instead for 
Did you mean: 

Mailserver on LInux. Help needed understanding it all!!

mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Mailserver on LInux. Help needed understanding it all!!

Been a casual Linux user (in addition to Windows.) for quite some time, and reasonably capable of most tasks.   I recently bought a SheevaPlug, which is a low-power ARM device about the size of a mains plug, with a 1.2Ghz ARM CPU, 512MB of flash, 512MB of RAM, and must say, it's amazing bit of kit.   Comes with Ubuntu 9.04 by default.
Anyway, I have almost everything running how I want it to be, my only other task for the plug to perform, is as a mail server.
I currently have a hotch-potch setup, where my main PC collects my email from Plusnets servers via POP3 , and I lose the ability to view the mail from my other PC's  I use IMAP on those, and can only view anything thats not been collected by my main PC, it also means I have several "sent" folders kicking around on different PCs
Figured it's time to centralise things.  My SheevaPlug has a nice big 2TB WesternDigial MyBook Mirror shoved in the back of it, which seems a ideal place to store my MBOX mail files, and then everything can access them via IMAP.
What I plan on doing is to have the Sheevaplug server collect my email from plusnet servers via POP3, and store them in a mailbox on the plug.  I then intend to serve that up via IMAP to any PC on my LAN than needs it.  I also want stuff sent via the IMAP server to appear in a single sent folder.
I have started tinkering, and got Dovecot IMAP server sorta running, (it only shows a single INBOX, I assume because it's never collected any mail).   I am now at the stage where I am trying to work out how all these disparate Linux mail systems work together.  I have no idea what a MTA actually is, I don't know the difference between my postfixes, my sendmails, my fetchmails and my procmails.   not sure which of those lot are needed, if either of them duplicate functionality of others, or even the best way to move forward with my setup..
Mail servers under linux seems to be a total nightmare to setup!  HELP!!!
14 REPLIES
Community Veteran
Posts: 3,789
Registered: 08-06-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Hi Mark,
I would use Postfix + Dovecot combined.
Firstly, work on using it as an outbound and internal mail server.  Ensure that Postfix is the default MTA (not sure how to do this on Ubuntu tbh) and you will (hopefully) find the config file at /etc/postfix/main.cf
It should be fairly well documented - the defaults are pretty much ok, but you are likely to have to set your domain name, and set your 'smarthost/relay host' to relay.plus.net .  I would also be tempted to use Maildir as the mailbox format (one file per email) as opposed to mbox (one file for the entire mailbox).  To ensure that the changes to the config file take effect, you should be able to do a 'postfix reload'
Now, you should be able to change at least one client to use the local IP of your Sheeva as it's SMTP server for sending.  If the email is for your domain, it will try to deliver locally either to a real user, or to an alias defined in /etc/aliases.  If you change /etc/aliases make sure you always run 'newaliases' afterwards to ensure the alias database is rebuilt.  If you send an 'external' email, Postfixc will recognise that it doesn't know the recipient, and forward it to your 'smarthost' - i.e. relay.plus.net
Next up, Dovecot.  The config file should be around /etc/dovecot.conf.  Ensure you enable the IMAP section (again, the file should be fairly well documented).  To ensure Dovecot has taken notice, issue an /etc/init.d/dovecot restart
Next up, you have a choice.  You can either use Fetchmail to pull your mail down using POP3/IMAP from the Plusnet servers (this can have problems with mail - usually stuff like mailing lists that has been 'bulk sent').  This will basically act like a POP3 client, download each mail individually, then pass it to Postfix to attempt to 'deliver' locally.
The other option is to request that Plusnet deliver your mail to your IP using SMTP.  This means you will need to forward port 25 on your router to the Sheeva's fixed IP.  Thus, any mail will be sent directly to Postfix on the Sheeva, and if you are offline will be queued up on autoturn.plus.net.
IMO, It would be better to 'test' using Fetchmail, and when you're happy that your local machine will deliver correctly, then to ask for the SMTP method to be used (it's available to turn on in the control panel for domains, IIRC.. Not sure if it's available for xxx.plus.com)
HTH as a starting point!
B.

Community Veteran
Posts: 3,789
Registered: 08-06-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Aha, seems Postfix is the default MTA on Ubuntu (good, it's bloody marvellous)
B.
Ben_Brown
Grafter
Posts: 2,839
Registered: 13-06-2007

Re: Mailserver on LInux. Help needed understanding it all!!

exim FTW! Postfix is ok for small installations to be fair, but exim scales a lot better. I'm a bit biased because I have loads of exim experience from looking after the mail platform here, and haven't used postfix for years.
Where'd you get the SheevaPlug from? I'm intrigued but can't seem to find anyone selling them (just done a pretty quick google tbh).
mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

All the SheevaPlug info is here:
http://www.plugcomputer.org/
And providors here:
http://www.plugcomputer.org/index.php/resources/plug-providers
I got mine from Globalscale in the US, it was a 4 week wait for it thou, it cost $99 + delivery and UK import tax (addition £13).  All in it was less than £100.  And it's a fantastic bit of kit for a home server.  I run a mediaserver, http, smb ensiper :-) and a few other goodies on it.  Normal load it consumes about 5W of power, which is rather good. My previous MiniITX system was 4x that with less CPU horses
As for the mail server, i'm gonna give it a shot again this weekend.
mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Following this guide for starers on Ubuntu postfix:
https://help.ubuntu.com/community/PostfixBasicSetupHowto
And another handy guide on getting SMTP authentication working with saslauthd:
http://www.greens.org/~cls/linux/howtos/smtp-auth-saslauthd.html
got as far as sending mails between local users on the ubuntu system...  I had a apt-get procmail as it was causing errors without it (this is a extremely cut down Ubuntu install as it all lives in 512MB of flash).
OK, decided saslauthd is a whole world of hurt.  I never managed to get it working, with all sorts of cryptic messages in the logs about "no secret in database".  Decided to leave it set to auth none for the moment....
I can see a IMAP inbox in Dovecot (and only a inbox, no other folders).  I can send mail via postfix to the outside world.  I feel after 5 hours of messing around and much shouting, I have made a small amount of progress. 
Things I still have to figure out and fix:
1/ How sending a email from my email client (Opera M2), makes the message appear in my IMAP sent folder.  This is not currently happening, I only have a INBOX, I created a "sent" folder, but unsurprisingly things aren't appearing there.  I don't see how that "wires up".  How a sent message via SMTP gets seen and stored by dovecot.
2/ getting my MX record updated so things get delivered straight to my inbox.   I have decided not to bother with fetching mail via fetchmail, and do it the proper way.  However before I open up SMTP ports on my router, I want to be confident  my server is secure.  I am not confident that the pain authentication is secure.
mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

OK, I figured the first problem out, where the mail gets stored is the responsibility of the mail client. so I had to tell Opera where to put sent mails.
I just got to figure out how to move all my disparate mail folders into the dovecot maildir.  I was going to use mbox as a storage format, as that is what Opera stores it's mail as, but this seems to be a very poor format, maildir seems a much more elegant solution.
mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

OK, nearing the end of my "quest".  I have all my existing mail from many different PC's all imported into my IMAP MailDir Inbox and Sent folders.
I enabled SMTP delivery on both my plusnet mail settings and my domain settings, I have opened up SMTP port 25 on my router and forwarded it to my sheevaplug static IP.
Nothing happens.  Now I am not sure how long it takes Plusnet to change things over, so it may be a case of waiting, or it may be a case of me having to set postfix to actually do something.
What initiates the connection?  Do I need to tell postfix to go to Plusnet servers and collect mail, or does PLusnet push it out to the IP address I specified and postfix sees it?
If I telnet to my external IP address from Windows using PUTY on port 25, I see:
220 Sheeva ESMTP Postfix (Ubuntu)
So I think it's working OK my end  (unless Windows is being smart and shortcutting and it's not actually going out and then back into my network).
VileReynard
Seasoned Pro
Posts: 10,822
Thanks: 245
Fixes: 10
Registered: 01-09-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Community Veteran
Posts: 3,789
Registered: 08-06-2007

Re: Mailserver on LInux. Help needed understanding it all!!

You'll have to wait for DNs to update (24-48 hours).
If you do:  dig yourdomain.co.uk from a shell, it should tell you the MX records for your domain.
If your connection is offline, your mails will be queued on the Autoturn server.  See This Post for details on how to elegantly dequeue them.
B.
mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

I have fingered  postmaster@autoturn.plus.net  Shocked
And I have done a "dig" but I don't know how to interpret the results it gave me.
root@sheeva:~# dig markgillespie.co.uk
; <<>> DiG 9.5.1-P2 <<>> markgillespie.co.uk
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50192
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;markgillespie.co.uk.          IN      A
;; ANSWER SECTION:
markgillespie.co.uk.    0      IN      A      67.215.65.132
;; Query time: 29 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Sun Sep 20 12:58:07 2009
;; MSG SIZE  rcvd: 53

The only other thing I need to ask, do I need to tell Postfix to accept connections from Plusnets mail server?  In my main.cf I only have:
mynetworks = 127.0.0.0/8, 192.168.1.0/24
VileReynard
Seasoned Pro
Posts: 10,822
Thanks: 245
Fixes: 10
Registered: 01-09-2007

Re: Mailserver on LInux. Help needed understanding it all!!

I did one of those - not as root - and it gives:-
Quote
jeremy@HECTOR:~$ dig markgillespie.co.uk
; <<>> DiG 9.5.1-P2 <<>> markgillespie.co.uk
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12318
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;markgillespie.co.uk. IN A
;; AUTHORITY SECTION:
markgillespie.co.uk. 10800 IN SOA ns1.force9.net. hostmaster.plus.net.uk. 2009092048 14400 1800 604800 86400
;; Query time: 22 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun Sep 20 14:50:59 2009
;; MSG SIZE  rcvd: 107

I don't know what it means either - but it looks "better" Smiley

mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Thanks to Barry I have it all working nicely.  My mail is finally centralized (and backed up).   The one thing I didn't consider, was that I would miss out on the very effective spam filtering that Plusnet does to my mail.
Since I started getting my mail direct, I can see how much spam I am really getting rather than not seeing...
Something to bear in mind if you plan host your own mail server.
I am tinkering with SpamAssassin, and see how it works on a lightweight embedded system, if it's too much for it, then I might revert back to collecting the mail via POP3 fetchmail so I can benefit from Plusnets Virus and Spam checking...
mgillespie
Grafter
Posts: 222
Registered: 08-04-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Well after a couple of weeks use, i thought i'd update this post.
Everything is working well, I got Spamassassin installed, and it's doing a grand job of managing my spam.  I also done some tweaks so a LED lights up on the front of the sheevaplug when I have unread (non-spam) mail messages. 
http://plugcomputer.org/plugforum/index.php?topic=795.0
Community Veteran
Posts: 3,789
Registered: 08-06-2007

Re: Mailserver on LInux. Help needed understanding it all!!

Glad to hear it Mark.
I would consider looking at Razor/pyzor and Dcc if you're using Spamassassin - it does help somewhat, although again you may need to check to see if the load is ok on the Plug. Smiley
B.