Totally Lost Setting up mail server - Please Help

Associate
Joined
1 Aug 2007
Posts
1,065
Hi all,

I'm new to linux and setting up a mail server. The reason im doing is because I want learn both. I want to be able to email [email protected] and know that its going through my mail server and stored on my PC (Not google or any other isp).

What I have..

PC with Debian Installed with gnome
Domain Name - So I can configure my own mx record and direct to my fixed isp address?
ISP with fixed IP Address.

I have read quite a bit about what's required for a mail server so I think this is required? Please correct

Mail User Agent (MUA) - Ok Debian has Evolution and my other PC Thunderbird.

Mail Transfer Agent (MTA)
- Ok when I installed debian I seleted mail server so EXIM was installed.

I presume exim handles the mail once it has been collected from my ISP and sorts into in maildirs?

I then installed courier-imap courier-imap-ssl. Is this the program that then allows me to configure Evolution Mail so I can access the mail collected and sorted by exim?

So before I start the configuration I still require a program that receives the email from my domainname address?

Is this whats called Mail Delivery Agent (MDA)? Does Exim do this as well or do I need Fetchmail?

Sorry I have so many questions.
 
What you need is a domain name with an mx record pointing to your mail server, then on the mail server you need something like qmail to deliver it, and squirrelmail or something if you want webmail.
 
Are you setting up this mail server at home?

If yes, you'll need to make sure your ISP will let you run a mail server (port 25) at home and then you'll need to forward the ports from your router to your server.

And as oldbag mentioned, you'll need to create a mx and a record to point your domain to your public (hopefully static) ip address, then configure the software on the server :)
 
One point to consider if you are thinking of running a mailserver is reliability. If you have an MX record pointing to your server and your server is offline or unable to receive for whatever reason you will lose any mail sent to it duing the down time.

Another option is to run a mailserver and get a domain including some externally hosted storage. You could then automatically fetch the email from this and/or any other email account at regular intervals (using something like fetchmail),keep it on your server and access it via imap. This way if your server goes down you don't lose mail.
 
If you're dedicated to going down the "host it yourself" route, the server you host performs 3 basic functions.

1) Sending mail you write to the rest of the world.
2) Receiving mail from the rest of the world to you.
3) Hosting your mailbox.

A typical set up, as you have installed, uses Exim to do the first two (these are routing-like things), and courier to be the IMAP server (this is what Evolution, or Outlook, or Thunderbird point at so you can read your mail.

Courier should require minimal configuration. The usual way of storing mail on your server is in the maildir format (big directory with lots of small files) although a previously way is called mbox format (one huuuuuge file). I'd stick with maildir as it's more flexible and maintainable, but uses up a bit more disk space. From memory, courier just requires you to tell it what format mailbox you use, and it's location. If it's maildir, your mailbox will be inside your user's home directory on the server, in a folder called .maildir or just Maildir. Mine is in /home/growse/.maildir/ on my mailserver, so that when I log into courier using a mail client, I log in as 'growse' and it knows to look in that directory for my mail. Mbox will be slightly different.

Exim is the slightly more complicated bit. Basically, you want to do something fairly simple with something that's very very powerful. You mention in your post that exim handles your mail as it's delivered from your ISP - this is true, assuming that your home server is the final point for your mail. Basically, what others have said about having an MX record point to your home static IP address so that the internet knows where to send you mail.

There's literally millions of guides out there on how to configure exim, but the highlights are thus: Exim has the concept of 'routers' and 'transports'. A router is a piece of config that decides what to do with a piece of mail, and a transport is an endpoint. For example, I have a router that says:

Code:
remote_smtp_smarthost:
  domains = ! +local_domains
  driver = manualroute
  transport = remote_smtp
  route_data = xx.xx.xx.xx

where xx.xx.xx.xx is my ISP mail servers. This basically says that any piece of mail received by Exim, that isn't destined for the domains it handles should be sent to the remote_smtp transport. Basically, any mail I write that's outbound. To stop me being an open relay and sending mail everywhere, there's a piece of config higher up that only accepts mail destined for non-local domains if it's (a) come from my local network (I'm the one sending it) or (b) if it's been authenticated (I'm the one sending it).


A transport is just a destination. I use three:

Code:
remote_smtp:
  driver = smtp
  hosts_require_auth = xx.xx.xx.xx
  return_path = [email protected]

local_delivery:
  driver = appendfile
  maildir_format = true
  directory = /home/growse/.maildir/
  delivery_date_add
  envelope_to_add
  return_path_add
  user = growse

spam_delivery:
  driver = appendfile
  maildir_format = true
  directory = /home/growse/.maildir/.spam/
  delivery_date_add
  envelope_to_add
  return_path_add
  user = growse

The first routes outgoing mail that I'm sending to my ISP's mailservers, who will then forward it on. The second is basically my inbox, and the third is basically my spam folder.

Once you get your head around that sort of thing, Exim becomes a lot easier. If you don't understand any of that, post back here and I (and others :)) will try and help you. As others have said as well, you'll need to forward port 25 on your router to your Exim computer, and basically leave it running all the time (it can't receive mail when it's off).

Oh, and for the record, I don't go with this Debian "lets break the config file down into tiny pieces" thing. I find one huge config file easier, as you're not constantly closing and opening files to try and remember where the bit of config you want is.
 
Last edited:
I always meant to do a "how my mail setup works", mostly because (a) I struggled with it for a long long time, and now it works and (b) it really does work damn well.

I'll do an expanded version of that and stick it on my blog methinks.
 
Hi Growse,

Thanks for your effort, I will be doing some more work on this during the weekend and post back with my results.

Thanks again
 
Back
Top Bottom