Project

General

Profile

Support #474

Installing iRedMail 0.8.7 Mail Server on FreeBSD

Added by Daniel Curtis over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Mail Server
Target version:
Start date:
11/12/2014
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

Description

One of the core services of the Internet is email, and as such I needed to setup a mail server for one of my projects. Rather than setting up postfix, dovecot, spamassassin, etc. by hand, I found the useful open source project iRedMail. Unfortunately, this project currently is not in the port tree, however the install script uses the ports tree to install each of the necessary packages. This guide uses a FreeBSD 9.2 jail created using FreeNAS, so it should work on a bare metal setup as well; also this guide assumes that SSH has been enabled and a separate user used to run administrative commands has been created.

Update the system

  • Login as root:
    su -
    
  • Update the ports tree
    portsnap fetch extract
    
  • Install portupgrade
    cd /usr/ports/ports-mgmt/portupgrade
    make install clean
    
  • Upgrade the base system
    portupgrade -a
    
  • Check the current hostname:
    hostname -f
    
    • The output should look similar to the following:
      mx.example.com
      

On FreeBSD, hostname is set in two files: /etc/rc.conf, /etc/hosts.

  • Add or modify the /etc/rc.conf file:
    hostname="mx.example.com" 
    
  • Add or modify the /etc/hosts file:
    127.0.0.1   mx.example.com mx localhost localhost.localdomain
    

Install iRedMail

  • Install bash
    portupgrade -Np shells/bash
    
  • (Optional) Install mercurial
    portupgrade -Np devel/mercurial
    
  • Fetch and extract the iRedMail stable installer:
    cd
    fetch https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.8.7.tar.bz2
    tar xjf iRedMail-0.8.7.tar.bz2
    cd iRedMail-0.8.7
    
    • Use the latest development installer (Recommended for FreeBSD 9 and higher)
      bash
      cd /usr/src
      hg clone https://bitbucket.org/zhb/iredmail
      cd iredmail/iRedMail
      
  • Run the iRedMail Installer:
    bash iRedMail.sh
    

Configure iRedMail

The install process will pull in all the required packages during installation. Since each mail server is a little different, my setup uses the following parameters:
  • Default mail storage path: /var/vmail
  • Preferred backend used to store mail accounts: MariaDB
  • First virtual domain name: example.com
  • Optional components:
    • DKIM signing/verification
    • iRedAdmin
    • Roundcubemail
    • phpMyAdmin
    • Awstats

When the installation finishes, all the login information and URLs will be placed in the iRedMail.tips file.

Troubleshooting

  • NOTE: The latest stable version, 0.8.7, uses the older version of apache2. I needed to run the following to prevent upgrades from defaulting to apache24:
    echo "USE_APACHE=22+" >> /etc/make.conf
    
  • NOTE: On newer FreeBSD systems apache22 is deprecated, and this will break the iRedMail installer since it depends on apache22. In order to fix this problem, edit functions/packages_freebsd.sh and make the following change:
    DEFAULT_VERSIONS+=python=2.7 python2=2.7 apache=2.2
    
  • NOTE: During the install I came across the following error:

apache22-2.2.29_2 AUTHN_DBD and DBD requires APR-util to have DBD support build in. Please rebuild APR at last with one DBD backend (MYSQL, PGSQL or SQLITE).

  • In order to fix this, I needed to reinstall apr1 (this is to compile the modules required for the database backend):
    cd /usr/ports/devel/apr1
    make reinstall clean
    
  • Then rerun the iRedMail Installer:
    cd ~/iRedMail-0.8.7
    bash iRedMail.sh
    

Install Getmail

  • Install getmail
    cd /usr/ports/mail/getmail
    portupgrade -Np
    

Configuring Getmail

  • Unlock the vmail user
    chsh -s /bin/sh vmail
    
  • Switch to the vmail user
    su - vmail
    
  • Set up the getmail configuration
    cd
    mkdir .getmail
    cp /usr/local/share/examples/getmail/getmailrc-examples .getmail/getmailrc
    

For user john, with an email address of , email user name john, a password of 1234, and an ISP whose pop server name is pop.example.com, we would like our getmailrc to look like this.

[options]
verbose = 0
read_all = false
delete = false

[retriever]
type = SimplePOP3Retriever
server = pop.example.com
username = john
password = 1234

[destination]
type = MDA_external
path = /usr/local/libexec/dovecot/deliver
arguments = ("-e", "-f", "%(sender)", "-d", "")

Testing Getmail

  • To test getmail simply type at a command prompt
    getmail -v
    

If all is set up successfully, you should see it polling your pop server and retrieving your mail.

Automating Getmail

Unlike fetchmail, getmail doesn't have a daemon option, so if you want it to poll your server at regular intervals, you will have to add a crontab entry. The man 5 crontab page explains things rather clearly, but a quick example.

  • On most systems, a user can edit his own crontab. So as user john you would do
    crontab -e
    

    And add the following
    */2 * * * * /usr/local/bin/getmail
    
    • This will run getmail every 2 minutes.

Resources


Files

iRedMail-0.8.7.tar.bz2 (110 KB) iRedMail-0.8.7.tar.bz2 iRedMail Installer Daniel Curtis, 11/12/2014 11:52 AM

Related issues

Copied to FreeBSD Administration - Support #537: Install a Mail Server With iRedMail 0.9.0 on FreeBSDClosedDaniel Curtis11/12/2014

Actions
#1

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • % Done changed from 0 to 30
#2

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#3

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#5

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • % Done changed from 30 to 60
#6

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#7

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#8

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • Status changed from New to In Progress
#9

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#10

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • % Done changed from 60 to 80
#11

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • Status changed from In Progress to Resolved
  • % Done changed from 80 to 100
#12

Updated by Daniel Curtis over 9 years ago

  • Status changed from Resolved to Closed
#13

Updated by Daniel Curtis about 9 years ago

  • Subject changed from Installing iRedMail Mail Server on FreeBSD 9.2 to Installing iRedMail 0.8.7 Mail Server on FreeBSD 9.2
#14

Updated by Daniel Curtis about 9 years ago

  • Copied to Support #537: Install a Mail Server With iRedMail 0.9.0 on FreeBSD added
#15

Updated by Daniel Curtis about 9 years ago

  • Subject changed from Installing iRedMail 0.8.7 Mail Server on FreeBSD 9.2 to Installing iRedMail 0.8.7 Mail Server on FreeBSD
  • Target version set to FreeBSD 9
#16

Updated by Daniel Curtis about 9 years ago

  • Category set to Mail Server

Also available in: Atom PDF