Raspberry Pi Infrastructure Series
I decided to start a series of articles that explain how to go about setting up various types of servers using the Raspberry Pi as a base for the server infrastructure. Thus, this one is about setting the Raspberry Pi to be a mail server using 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.
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 my article here (the article is targeted for the Pogoplug but the commands will be the same).
UPDATE: Before we begin the process, Citadel is automatically going to try and start using IPv6 so we need to load the module before proceeding with the installation.
sudo modprobe ipv6
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.
sudo apt-get update
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 Apache (or Nginx).
Enter the port you want the webmail interface to operate on. Port 80 is usually fine unless you have something already binding that port.
UPDATE: Unfortunately it doesn't matter what you port you enter here as something in the configuration process is broke and it will automatically default to port 80 anyway.
Previous explanation applies for this. This allows you to utilize SSL for a secure solution.
Select a default language if you like.
UPDATE: Once that's done the service should start, and you should see an error along the lines of Failed to adjust ownership of: /etc/citadel/netconfigs/7. For whatever reason Citadel didn't create this directory but we can go ahead and run the following commands to fix that.
sudo mkdir /etc/citadel/netconfigs
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 still tries to bind IPv6 addresses (which is why we had to load the module beforehand). It basically doesn't set any of the settings you specified in the setup. 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.
UPDATE: If you need to change the port that webcit runs on. You'll to need to open up /etc/default/webcit and modify the export WEBCIT_HTTP_PORT='80' to match whatever port you want.
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.
Leave a comment
Twinclouds Hi, Ben: Thank you for your good how-to. Very helpful. My purpose is to set up my own email using my domain, say "mydomain.com" hosted on zoneedit. I have followed your instructions and everything went smoothly. Now, come to configuration, I have two questions. First, should I simply enter "mydomain.com" in Local host aliases section? Secondly, for setting MX record, what should I use as the Host? Also "mydomain.com"? Thank you in advance for your help.
Jérémy from France Thank you for this tuto, that was helpfull... All has been installed correctly, but when I try to connect on SMTPS + IMAPS, I can't get nor receive emails, even if my ports are open...
Matt Thank you for this tutorial, it took me less than 1 hour and it works perfectly!
Alvin I have the same login screen problem as everybody else. I think it is a cookie problem.
I got round it by opening a new private browsing session and trying again.
Sander If you are running apache you need to make a symlink in /etc/apache2/conf.d to webcit.conf
sudo ln -s /etc/citadel/webcit.conf webcit.conf
for some reason the setup doesn't do this for you.
After a reboot you can go to citadel loginpage on http://yourserver/webcit
Thanks for this great tutorial, but i have the same issue like others, i cannot see the login screen i only read this message:
"Welcome to Citadel Server!
This logon banner resides in /etc/citadel/messages//hello -- please customize it for your site."
I disabled the Ad-Block extensions and the issue remains.
Yep Update! I checked with Google Chrome and the login window charges ok! Maybe is Safari the problem?
Vlad m Will this work on my Pi while hosting a website with Apache of Lightpd?
Ben Hanna Are you following the tutorial with a fresh install of Raspbian?
If you follow the tutorial word for word with a fresh copy of Raspbian then everything should work. If you already have a web server like Apache, Nginx, or Lighttpd installed that can sometimes cause issues.
Did you run the Citadel setup as specified in the tutorial?
Martin Like Luke I am unable to get past the login point as the button does not work. Can you please advise me how to proceed.
May I suggest that it might be a good addition to your tutorial to have a problem section.
The tutorial I found excellent as easy to follow.
Luke Hi I followed your instructions, when I log onto the server for the first time I just get a login button when I hit it nothing happens. I configured citadel to use just the internal account. I'm sure I have done something wrong but can't think what.
Andre Hello, I have a static ip address 220.127.116.11 and want my RasPi to be available under this ip to manage all email addresses of the domains owned by me.Do I have to replace the 0.0.0.0 with my ip?How should the DNS MX look like?@ 86400 IN MX 10 18.104.22.168.Thank you all for your help.André
John Citadel is going great on my RPI as mail server. Just one snag. Mail retrieval is not deleting the retrieved mail from server despite not having the keep email on server box ticked?
Philippe Hello , I have a 550 error when I try to send mails to current user of citadel but not to the admin, Does anybody knows the solution to this issue ?
Christian to Paolospane: did you check administration->view the outbound SMTP queue? if you are working without (fallback) smarthost you can check here for failure messages.
Paolospane Hi all,
I followed the guide and i installed few days ago Citadel with domain Name: xx.dyndns.org.
I can receive in the mailbox "admin" the mails comes from firstname.lastname@example.org.
The issue is that I'm not able to send mails from email@example.com to firstname.lastname@example.org.
I'm worder about it because my first test afterward the installation, it was able to send mails (i received them in the SPAM box). I do not know what it happened. I'm thinking is an gmail's filter to block the mails comes from to dynamicIP.
I checked in the log files and i've this error message :
"No external notifiers configured on system/user" but I do not think is an stuck error.
Does anybody knows the solution about this issue?
I want to use Citadel together with Nginx.
I followed your tutorial but setup the option Apache2. It seems that the Citadel webserver is still running.
Ho can I run Citadel without the included webserver?
Can someone give me a hint how to setup Nginx for this?
My plan is to use Wordpress together with Citadel with few resources. Nginx and Wordpress is already running.
Christian Great post; learned a lot from this. I've Citadel up and running in combination with a web server (ArchLinux, Apache, MySQL,Php: have a look at www.junges.nl) Installation of Drupal and integration with Citadel has been quite easy as has been the installation and integration of spamassassin. Right now I'm experiencing problems with the integration of CLAMAV (saying with each incoming mail: Connecting to clamd at <127.0.0.1>; connect() failed: Connection refused. Another problem is the lack of a SPF record on my (registrar's)DNS server. So I have to relay outgoing message via my ISP's mail server and incoming mail will not reach me in most cases because the google's and yahoo's of this world are checking the SPF record. I will put the details on my own site
Michele Hi, I just installed Citadel in my Rpi. I've already Apache2 installed with Mysql and Php.
I set the port on 88 and it run well.
If I type ip_Rpi:88 I go to the Citadel Home Page, if I enter just my IP the port n° 80 open to Apache and I got my web site.
Now I try to set-up the email-server. Thank alot from Italy!
Ben Hanna In order to setup email for a domain in the Administration section of web interface you need add the domain name to the Local Host Aliases as well as the Directory Domains.
That's all the setup required for Citadel, the rest is properly configuring the MX record for your domain to point to your Citadel server, which usually involves forwarding port 25 on router to the server as well.
Drew Does anyone know of documentation to explain the proper setup for email for a domain through the GUI. Looks like the citadel site only explains it as if there were no web interface
alex how to add smarthost login?
sai is mad same problem as Saeid and Thombose. Anyone know how to fix or where we are going wrong?
Ben Hanna The only situation I can reproduce where the error occurs that webcit says it's unable to connect or stay connected is when /usr/lib/citadel-server/setup has not been run after the package install. I would recommend re-running sudo /usr/lib/citadel-server/setup and making sure you specify 0.0.0.0 for the IP address to listen on. That netconfig error isn't anything serious (I get it every time and the system works fine for me).
Ben Hanna @Saeid, @iZero, @Thombose: Can any of you verify if the Citadel server is actually running? You can use 'pgrep citserver' which should tell you the process ID if it's running.
iZero I gave the same issue, I haven't got Apache installed, I use "lighty" on Port 80
I have followed your post and changed the WEBCIT_HTTP_PORT='8085' and restarted but without luck.
Original configuration gave the same error at the end as Thombose (23 Sep 2012)
Saeid I have a same issue "Thombose" has posted on Sept. 23, 2012
can you please help?
Thombose Hi again,
I read your new post and adapted the changes. But my Apache runs on port 8080. If I enter ip:8080 i get my apache page. If I enter ip/webcit:8080 I doesnt work. If I enter ip:8504 I get nothing either and if I use ip:8080/webcit/ I get "requested URL /webcit/ was not found on this server". In my previous config (see previous post) I had at least something citadel related, so I'm going back there :) but still the permissions issue there :(
I was trying this out. I have an Apache server running and an ISP blocking all ports <1024. So I changed listening port to 8504 and HTTP port tot 8083. I had however an error during the last phase of the installation:
Message from syslogd@raspberrypi at Sep 23 22:58:35 ...
citserver: Failed to adjust ownership of: /etc/citadel/netconfigs/7 [No such file or directory]
When I try to open the admin panel on ip:8083 it says: This program was unable to connect or stay connected to the Citadel server. Please report this problem to your system administrator.
Do you have any idea? Thanx in advance!! :)
Ben Hanna @Bum, @SanChip: I just published a post that explains how to fix the issue you're having with Apache.
Ash Hi Ben, great tutorial. What version of citadel are you using? I am having trouble with smart hosts and email stuck in the queue. I read that 8.11 has issues. Thanks
Bum I have the same problem, adding a port (2000) does not help. ben could you tell us how to configure citadel to be available with apache ?
would be great!
Ben Hanna Sounds like you've probably got Apache or some other web server installed also. Thus, Citadel isn't answering your requests on port 80. Try typing your RPi address with port 2000 specified (e.g. 22.214.171.124:2000), it may be running the interface on this port since a web server is already running.
When I follwed all of these steps but when I try to access the Administration ( i typed my RPi host adress) i get the default webpage. (Something like "It's works!..") . Where can i find the Administration panel instead?