Blue Flower

Sunday, 05 July 2015 13:15

Upgrading and Maintaining the Qmail System

Written by

Upgrading your ports and maintaining them are pretty easy. The first thing I would recommend is installing portupgrade from /usr/ports/sysutils/portupgrade. Once that is installed, you can run man portupgrade or just run portupgrade -r name. The -r switch means to upgrade everything recursively. Recurvisly meaning all of it's dependancies, or more simply, anything the program requires. You can do this for anything else not related to qmail or any of its programs. So for instance portupgrade -r kde, it will upgrade kde and all it's dependancies.

Another thing I would recommend using is portaudit. If you have your system setup correctly, You will get portaudit reports in your daily security logs. This will give you any warnings about any obsolete packages and/or any security warnings in regards to anything being installed.

What I am going to suggest in the next few pages is the recommended way to upgrade programs from ports. Mostly we will be running through backing up .conf files and running portupgrade and then making sure everything is chmodded or chowned correctly.

Qmail - Qmail doesn't require any type of upgrades. Qmail hasn't been upgraded since 1997 or 1998 but it is very stable and very secure.

UCSPI-TCP - Pretty much the same as qmail. I don't think has changed at all. Quite honestly, I have never upgraded it and I haven't ever had a problem with running any old/previous versions.

Daemontools - Again, Pretty much the same as qmail or UCSPI-TCP.

Ezmlm-idx - This can change from time to time. I would first backup your list which resides in ~vpopmail/domains/ before upgrading the port. Then, run portupgrade -r ezmlm-idx and then check to make sure your list is intact before deleting your backup.

Qmail-Autoresponder - As of 8/7/14 you need to create a symlink for delivermail as follows if you have not already. Just run the following command: ln -s /usr/local/bin/maildrop-deliverquota /usr/local/bin/deliverquota. otherwise This can be upgraded when new versions come out. A simple portupgrade -r qmail-autoresponder works fine in most cases.

Vpopmail -

At this point where the skel patch is no more, It is fairly easy to upgrade vpopmail from one version to the next. If your security run output or portaudit commands tell you that vpopmail need to be upgraded, run the following commands:

# cd /usr/ports/mail/vpopmail
# make CONFIGURE_ARGS="--enable-logging=p --enable-onchange-script"
# make deinstall
# make reinstall

Please make sure to run the following after upgrading vpopmail to make sure it works ok with TLS/SSL:

# cd ~vpopmail/bin
# chmod 6711 vchkpw
# chown vpopmail:vchkpw vchkpw

SpamAssassin - When I have run portupgrades with Spamassassin in the past, I usually don't run into any issues except the upgrade from 2.6x to 3.0.1. There were quite a few changes from version to version including some of the required modules that were new, like the SPF addon for it and such. If you do run a portupgrade on Spamassassin, I would go to Spamassassins website and read the README files under the download section of the site. There it will tell you any changes/modifications that have been done since the previos version. I would also check the rules under /usr/local/etc/mail/spamassassin file, specifically, to see if any additions or deletions were made.

Restart Spamassassin and then we will need to update the qmail-scanner database by running the following commands:

# setuidgid qscand /var/qmail/bin/ -z
# setuidgid qscand /var/qmail/bin/ -g
# setuidgid qscand /var/qmail/bin/ -p (If you're running qms 2.x)

This will update the header info and the qmail-scanner database and keep everything up to date.

ClamAV - ClamAV is probably the worst one out of all of them all but I make it easy for you, ClamAV changes almost every three months, possibly sooner. I would recommend backing up the clamd.conf and freshclam.conf in /usr/local/etc and then run portupgrade -r clamav. Then chown the following folders:

# chown -R qscand:qscand /var/log/clamav
# chown -R qscand:qscand /var/run/clamav/
# chown qscand:qscand /var/db/clamav/

I would then copy the backups of clamd.conf and freshclam.conf back to /usr/local/etc and then run freshclam to make sure evrything is working perfectly. Restart clamd and then we will need to update the qmail-scanner database by running the following commands:

# setuidgid qscand /var/qmail/bin/ -z
# setuidgid qscand /var/qmail/bin/ -g
# setuidgid qscand /var/qmail/bin/ -p (If you're running qms 2.x)

This will update the header info and the qmail-scanner database and keep everything up to date.

You will want to restart ClamAV.

Qmail-scanner - At the time of this writing, I would NOT recommend doing a portupgrade of qmail-scanner. There are a few reasons why. First, It does not even reqister with the packages system as we run the configure commands manually. Second we manually patch it with the qms-analog patch to get the nifty qmail-analog reports. So if a new vesion of qmail-scanner is released, I will update the documentation within a few days of it being released.

Qmailadmin - This is something else I wouldn't recommend doing a portupgrade on. When the new version comes out just make deinstall on the port and run through the guide as normal only using the newest version from ports. It just can't get any easier than that!

vqAdmin - Nothing needs to be backed up here. Just make deinstall the port and then follow the guide when the the new version comes out.

Dovecot - A simple portupgrade and a restart shouldn't be an issue at all.

Squirrelmail - This one is a rarity but every so often a squirrelmail upgrade does come up and if it does, backup your squirrelmail folder and then run a portupgrade -r squirrelmail and then double-check to make sure your conf files are setup correctly as they might change.


it probably wouldn't be a bad idea to rotate the qmail-scanner logs as they can get huge. These logs are stored in /var/spool/qmailscan and I would suggest adding the following to your /etc/newsyslog.conf:

/var/spool/qmailscan/qmail-queue.log qscand:qscand 600 5 256 * JC
/var/spool/qmailscan/qms-events.log qscand:qscand 600 5 256 * JC
/var/spool/qmailscan/quarantine.log qscand:qscand 660 7 * @T00 JC

If you would like a description of what each section does, do this:

# man 5 newsyslog.conf

The /var/log/mallog file is already rotated in newsyslog.conf once a day.

Saturday, 24 October 2015 16:08

Enabling Client-Side filters

Written by

If you would like your users to be ble to setup their own custom rules, you can do this with managesieve as shown below.

# cd /usr/ports/mail/dovecot-managesieve
# make install clean

You can enable the managesieve service in dovecot by adding managesieve to the protocols in dovecot.conf

# vi /usr/local/etc/dovecot.conf

add managesieve to the protocols setting. Save and then restart dovecot:

# svc -t /service/dovecot

Next we need to check what port managesieve is running on. Run sockstat -l4 and look for the following:

dovecot  managesiev 23920 4  tcp4   *:2000                *:*
dovecot  managesiev 23919 4  tcp4   *:2000                *:*

This is telling you that managesieve is running on port 2000. I have marked the relevant sections above in red. Now lets copy a few things:

# cd /usr/local/www/roundcube/plugins/managesieve/
# cp
# vi

And at the top we need to match the port number with the port we found when running sockstat -l4.

$config['managesieve_port'] = 2000;

Save, exit and run the following:

# cd /usr/local/www/roundcube/config/
# vi

and add managesieve to the plugins section:


Save and exit. You should now have the filter enabled and working on roundcube. Further information on configuration can be found at:

Sunday, 27 September 2015 03:20


Written by

Alternate AMD64 installation

I  have had trouble with the AMD installation from time to time. If you have trouble sending or receiving please try this alternate method:

# cd ~root
# fetch
# cd netqmail-1.06
# qmailctl stop
# make man
# make setup check

Now lets reinstall qmail

# cd /usr/ports/mail/qmail
# make reinstall

Once you're finished lets start qmail

# qmailctl start

Sending or Receiving issues

If you are having issues sending or receiving please check the following logs:

qmail-send logs

# tail -f /var/log/qmail/qmail-send/current | tai64nlocal

qmail-smtpd logs

# tail -f /var/log/qmail/qmail-smtpd/current | tai64nlocal

qmail-smtpd-ssl (Port 465)

# tail -f /var/log/qmail/qmail-smtpd-ssl/current | tai64nlocal


# tail -f /var/log/qmail/dovecot/current | tai64nlocal


# tail -f /var/log/qmail/qspamd/current | tai64nlocal


# tail -f /var/log/qmail/clamav/current | tai64nlocal

451 qq Temporary problem

if you get the dreaded 451 qq temporary problem click here



Sunday, 27 September 2015 03:01

Adding Junk/Not Junk Features to Roundcube

Written by

In this walkthrough we will add the Junk/Not Junk buttons to the Roundcube interface. This will allow users to report spam and also report non-spam. There is also an included variable; Once the users have read the Junk mail you will be able to see the files in a predetermined spam box. This is completely optional but will give you more control over what users report.

First lets download the plugin and install it.

# cd /usr/local/www/roundcube/plugins
# fetch
# unzip
# mv Roundcube-Plugin-Mark-as-Junk-2-master markasjunk2
# cd /usr/local/www/roundcube/config
# vi

look for plugins array:

$config['plugins'] = array(



Looks like


Save and Exit. Now copy the default so this will work properly.

# cd /usr/local/www/roundcube/plugins/markasjunk2
# cp

The defaults are fine. No changes are needed. When you mark an email as Spam it will try to move it to a Junk folder which will not exist. To make this seamless for your users we will need to create a symbolic link for .Junk to point to spam. We can do this in the ~vpopmail/skel folder as follows:

# cd ~vpopmail/skel/Maildir
# ln -s .Spam/ .Junk

The following section is optional. If you would like to see users' read Spam messages you can direct the read messages to a master spambox or just put this in a postmaster mailbox. It's entirely up to you.

Lets add This email address is being protected from spambots. You need JavaScript enabled to view it. first

# ~vpopmail/bin/vadduser This email address is being protected from spambots. You need JavaScript enabled to view it.

Now lets create a symbolic link to the spambox Junk folder.

# cd ~vpopmail/skel/Maildir/.Junk
# rm -R cur

change spambox to the sa-learn catchall user for all domains

# ln -s /usr/home/vpopmail/domains/ cur

Special thanks to Steve Donohue

Tuesday, 11 August 2015 18:14

Installing Qmailadmin

Written by

QmailAdmin is a cgi program for administering Qmail with vchkpw. It provides a web interface to create users, aliases, install ezmlm lists and also configure mailing robots. For more information, Please see

We need to enable the cgi setting in the httpd.conf file as follows:

# vi /usr/local/etc/apache24/httpd.conf

Uncomment this line:

LoadModule cgi_module libexec/apache24/

Now restart apache:

# /usr/local/etc/rc.d/apache24 restart

We will want to extract qmailadmin and apply John Simpsons onchange patch. Since qmailadmin doesn't support onchange out of the box, We need to add support for it:

# cd ~root
# fetch
# tar zxvf qmailadmin-1.2.16.tar.gz
# cd qmailadmin-1.2.16
# fetch
# patch < qmailadmin-1.2.12-onchange.3.patch

Don't be too concerned about the version conflicts. The patch applies cleanly without errors. You should get a fairly short output.

We now want run the configure command for qmailadmin. Please change the sections cgibindir, htmldir and imagedir to the cgi, html and image paths on your system.

Please type the make CONFIGURE_ARGS line in as ONE COMPLETE LINE!!!

./configure --enable-modify-spam=Y --enable-spam-command='|preline -f /usr/local/bin/maildrop mailfilter' --enable-htmldir=/usr/local/www/apache24/data --enable-cgibindir=/usr/local/www/apache24/cgi-bin --enable-imagedir=/usr/local/www/apache24/data/images --enable-qmaildir=/var/qmail --enable-vpopuser=vpopmail --enable-vpopgroup=vchkpw --enable-autoresponder-path=/usr/local/bin --enable-ezmlmdir=/usr/local/bin/ezmlm --enable-modify-quota --disable-ezmlm-mysql

Run the following to install qmailadmin:

# make
# make install-strip

If that compiles with no errors, qmailadmin is installed.

Copying image files

We need to copy the image files so they appear on the qmailadmin page:

# mkdir /usr/local/www/apache24/data/images /usr/local/www/apache24/data/images/qmailadmin/ (You may or may not need to run this command)
# cp -Rp /root/qmailadmin-1.2.16/images/* /usr/local/www/apache24/data/images/qmailadmin/

Configuring qmailadmin

When we add new users via qmailadmin, we want Spam Fighting turned on by default. Edit the following:

# vi /usr/local/share/qmailadmin/html/add_user.html

and then do a search for

<input type="checkbox" name="spamcheck">

and change it to

<input type="checkbox" name="spamcheck" checked>

This allows the "Spam Detection" box in the users email-account to automatically be checked when each user in qmailadmin is created.

That is it for configuring qmailadmin! If you go to you should see the logon screen. You can create some mailboxes for your domain if you like. If you need to add a domain, I would use the command line tool at ~vpopmail/bin/vadddomain

Sunday, 05 July 2015 13:17

Installing Roundcube

Written by


Apache 2.4+, Mysql Server 5.1+ and php5.6. Anything that depends on php5 not already installed the port will install for you.

The Roundcube webmail software is available in FreeBSD ports. If you want to learn more about FreeBSD packages and ports, please read The FreeBSD Handbook, chapter 4.

The ports for Roundcube webmail is available in /usr/ports/mail/roundcube. To install roundcube, you will need to type the following:

# cd /usr/ports/mail/roundcube
# make install clean

Make sure the following options are checked:


You will also want to install the following ports if they are not installed already.

# cd /usr/ports/graphics/php56-exif
# make install clean
# cd /usr/ports/security/php56-openssl
# make install clean
# cd /usr/ports/security/php56-mcrypt
# make install clean
# cd /usr/ports/sysutils/php56-fileinfo
# make install clean

By default, roundcube is installed in /usr/local/www/roundcube/

Now, I’m going to symlink the roundcube folder as follows:

# cd /usr/local/www/apache24/data
# ln -s /usr/local/www/roundcube/ .

To create a database in mysql do the following:

# mysql -u root -p

Type in your password at the prompt. Then lets create the roundcube database.

# create database Roundcube;

Now we need to run the following 3 commands:

GRANT select,insert,update,delete,create,drop ON Roundcube.* TO myusername@localhost IDENTIFIED BY 'mypassword';

Now lets copy the default dovecot configuration file:

# cd /usr/local/www/roundcube/config
# cp /root/qmail/

Now we will want to open and change the following settings:

$config['dbdsnw'] = 'mysql://username:secretpass@localhost/database';

$config['default_host'] = 'localhost';

$config['smtp_port'] = 465;

Now lets edit some of the roundcube defaults to make things easier for new users:

# cd /usr/local/www/roundcube/config
# vi

Now we will want to open and change the following settings:

$config['show_images'] = 1;

$config['preview_pane'] = true;

Now, you need to import the database structure into your roundcube database. You can copy and paste them into phpMyAdmin or you can use the following command:

# cd /usr/local/www/roundcube/SQL
# mysql -u user -p database < mysql.initial.sql

All done, congratulations! You have installed roundcube on your server. You can access your roundcube webmail on

http://localhost/roundcube/ (You can change your localhost to your hostname).

You can now login with your username and password on your IMAP server.


The antiBruteForce Plugin is to prevent brute force user and pass attempts on Rouncube Webmail - Autoban feature with White List feature.

# cd /usr/local/www/roundcube/plugins
# fetch
# tar zxvf antiBruteForce_v2.0.tar.gz
# cd /usr/local/www/roundcube/config
# vi

Under plugins add the antibruteforce plugin line:


Now your plugins should look like:


Now let's restart apache for good measure:

# /usr/local/etc/rc.d/apache24 restart

Enabling the Roundcube Recipient To Contact Plugin

Recipient To Contact is a plugin to quickly add new contacts to address books. When sending an email to recipients that aren't in the address book, this plugin displays a form to quickly save these contacts. Inspired by Automatic Addressbook plugin.

We need to enable the jqueryui plugin first and then download the Recipient-To-Contact plugin and then enable both plugins.

# cd /usr/local/www/roundcube/plugins/jqueryui
# cp
# cd ~root
# fetch
# unzip
# cd Roundcube-Plugin-Recipient-To-Contact-master/
# mv recipient_to_contact/ /usr/local/www/roundcube/plugins/
# cd /usr/local/www/roundcube/config
# vi

Now under the '// List of active plugins (in plugins/ directory)' section of the add the two sections below:


It should now appear like the following:

// List of active plugins (in plugins/ directory)
$config['plugins'] = array(

If you log out and log back into roundcube it should work fine.

You can find additional roundcube plugins here

Page 4 of 23