Friday , 29 August 2014

Running a mail server on the Raspberry Pi (Citadel)

The first thing we need to understand in setting up a mail server are the protocols that need to be in place. The most basic mail server requires two protocols to function, one to retrieve e-mail (IMAP/POP3) and one to send and accept mail (SMTP). Usually these function operate as two different services. On Linux platforms Postfix and Sendmail are commonly used for SMTP and either Dovecot or Courier-IMAP are used for IMAP. Normally, these can be somewhat of a pain to configure and are usually tied to accounts on the actual host system. Wouldn’t it be nice if we could have all this functionality wrapped into one application? Well, that’s where Citadel comes into play.

Without going into to too much detail Citadel is an open-source project that originated as a BBS system (and still serves that function) but gradually took on the role of providing mail services. The best thing about using Citadel is that it’s basically a black-box application, meaning it doesn’t rely on a bunch of hooks and dependencies into the system (this makes it more portable since it’s self-contained). And it doesn’t stop there, Citadel is loaded with the following the features.

  • SMTP, IMAP, POP3 protocols supported
  • Supports XMPP (Citadel can act as a Jabber server for instant messaging)
  • Provides a fast webmail interface
  • Easily hooks into spamassassin and ClamAV for spam and virus filtering
  • Supports authentication against LDAP or Active Directory
  • Basic groupware functionality (Calendars, Meetings, Address Book, Notes, Tasks)

And to top it all off, Citadel is written in C as a native application so you don’t have to worry about an interpreted language (like PHP/Python) slowing you down.

So let’s get right down to installing it. For this tutorial I’m going to be using the Official Raspbian “Wheezy” image as my base system. If you want to install Citadel under Arch Linux on the Raspberry Pi please see this article here.

Thankfully, Debian makes the Citadel installation pretty easy as it’s included in Debian repositories. You can compile Citadel yourself but on an ARM like the Pi it usually takes 2 – 3 hours. So we’re going to make sure our sources are up-to-date and then install the citadel-suite package.

After a few mintues you should see the first screen. This is asking what interface we want to listen on. 0.0.0.0 means Citadel will listen on all addresses, generally speaking this is fine so just hit OK.

The next screen will ask you how you want to authenticate users. For now lets select Internal, this means users will be stored in Citadel’s own database. Host will use accounts that are on the Linux box serving Citadel. LDAP and Active Directory are for tying into a more advanced directory structure.

Enter the name of the user that you want to have admin privileges, this user will be able to make changes to the Citadel System-Wide configuration.

Enter a password for the admin user.

For now select Internal but if you were hosting other web sites on the same machine and wanted to serve other content simultaneously on Port 80 you can proxy the lighttpd (or Apache, or Nginx).

Enter the port you want the webmail interface to operate on. Port 2000 is usually fine unless you have something already binding that port. (Port 80 usualy uses by web servers)

Previous explanation applies for this. This allows you to utilize SSL for a secure solution.

Select a default language if you like.

After everything is done you’ll likely see some errors at the end like this.

Apparently something is broken with the Debian package so that even though we told Citadel to listen on 0.0.0.0 for IPv4 addresses, it’s actually trying to bind IPv6 addresses (Citadel does support this). What we have to do to fix this is manually run Citadel’s setup program in which you’ll need to re-enter some of the setup information you just entered.

Once again the admin user.

And the password.

Just leave this blank, citadel is the proper user. Debian creates this user during the install process.

This is what causes the problem, * tells the program to bind on IPv4 and IPv6. We need to enter 0.0.0.0 or a specific IP here.

Leave this blank, the default is fine.

Once again, choose your authentication method.

Here you can go ahead and say Yes, I don’t know of anything yet that this will break.

Once that’s done, Debian should reload the Citadel server. However, let’s reboot the machine just to make sure we’re running clean.

Now point your browser to the Raspberry Pi’s IP address (or hostname if you’ve got it mapped with DNS) and you should see the login screen. Enter your admin credentials here to proceed.

First thing you’ll want to do is head to Administration.

Now we’re going to go to Domain names and Internet mail configuration. Here you’ll need to add the domains you want to receive mail for under the Local host aliases.

Back at the Administration screen there’s nothing you really need to edit in the System-wide configuration at this point. But you’ll probably want to create a user or two by going to Add, change, delete user accounts.

At this point Citadel is installed and ready to go, just setup your appropriate MX records to point your server and mail should start coming in.

 

 

p5rn7vb

About AliOs

AliOs

Leave a Reply