Blue Flower

Tuesday, 17 May 2016 16:08

Setting up the TLS Service

Written by

Setting up the TLS Service on port 587 is not absolutely necessary but a lot of apple devices require this. The folders and run files are in place so all we need to do is setup the IP and then setup the service. I have also created a new qmailctl script that can handle the TLS service.


# cd /var/qmail/supervise/qmail-smtpd-tls
# vi run

You should set the following value:

IP=1.2.3.4 Substitute your own IP address. Do not leave this set to 0 without a good reason.

Save and then create the TLS Service by running the following command:


# ln -s /var/qmail/supervise/qmail-smtpd-tls /service/

Then check the service


# svstat /service/qmail-smtpd-tls/ /service/qmail-smtpd-tls/log/
/service/qmail-smtpd-tls/: up (pid 37035) 9 seconds
/service/qmail-smtpd-tls/log/: up (pid 37036) 9 seconds


it is important to note that if you use Microsoft Outlook to send mail via TLS you set the port to 587 but then under the section "Use the following type of encrypted connecttion" set this to AUTO.

If you want the qmailctl file to handle the TLS service copy this file:


# cd /var/qmail/bin
# cp qmailctl_tls qmailctl

When you run qmailctl it should now show the tls service.

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/domain.xxx/listname 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 http://www.spamassassin.org 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 local.cf, 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/qmail-scanner-queue.pl -z
# setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -g
# setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -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/qmail-scanner-queue.pl -z
# setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -g
# setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -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.

Logs

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 config.inc.php.dist config.inc.php
# vi config.inc.php

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 config.inc.php

and add managesieve to the plugins section:


   'managesieve'

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

http://Wiki.Dovecot.org/ManageSieve

Sunday, 27 September 2015 03:20

Troubleshooting

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 http://freebsdrocks.net/qmail2/netqmail-valid.tgz
# 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

dovecot

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

spamd

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

clamav

# 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 https://github.com/JohnDoh/Roundcube-Plugin-Mark-as-Junk-2/archive/master.zip
# unzip master.zip
# mv Roundcube-Plugin-Mark-as-Junk-2-master markasjunk2
# cd /usr/local/www/roundcube/config
# vi config.inc.php

look for plugins array:

$config['plugins'] = array(
    'archive',
    'zipdownload',
    'managesieve',
    'jqueryui',
    'recipient_to_contact',

add

    'markasjunk2'

Looks like

 'archive',
    'zipdownload',
    'managesieve',
    'jqueryui',
    'recipient_to_contact',
    'markasjunk2'

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


# cd /usr/local/www/roundcube/plugins/markasjunk2
# cp config.inc.php.dist config.inc.php

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/testdomain.com/spambox/Maildir/cur 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 http://www.inter7.com/qmailadmin/

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/mod_cgi.so

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 http://freebsdrocks.net/qmail2/qmailadmin-1.2.16.tar.gz
# tar zxvf qmailadmin-1.2.16.tar.gz
# cd qmailadmin-1.2.16
# fetch http://freebsdrocks.net/qmail2/qmailadmin-1.2.12-onchange.3.patch
# 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 http://www.domain.xxx/cgi-bin/qmailadmin 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

Page 4 of 23