Posts

How do I enable and disable Roundcube plugins?

This article covers how to enable and disable plugins, but does not cover how to configure any specific plugins.

IMPORTANT: A misconfigured plugin could cause roundcube to fail. Always backup before making changes.

To see a list of your available plugins

ls /usr/local/topicdesk/roundcube/WebApp/plugins/
Let’s be friendly and enable: emoticons

Plugins are enabled/disabled in the roundcube configuration file. We’ll use pico to edit the file.

sudo pico /usr/local/topicdesk/roundcube/WebApp/config/config.inc.php

Look for the plugin array, it will look something like this
$config['plugins'] = array('image_paster','html5_notifier','chbox','carddav','managesieve');

To enable show_additional_headers add it to the array, so it looks like this:
$config['plugins'] = array('image_paster','html5_notifier','chbox','carddav','managesieve','emoticons');

Logout and Login to Roundcube and now you have:

Roundcube WebMail Emoticons

To disable plugins

If a plugin causes roundcube to fail or you simply don’t need it – you remove the plugin from the array.

sudo pico /usr/local/topicdesk/roundcube/WebApp/config/config.inc.php

SpamAssassin Filter for New TLDs (.xyz .info .ninja etc)

Have you seen an increased spam from new TLDs (top level domains like these)?

.link, .xyz, .info, .ninja

This short tutorial demonstrates how to create a filter to add points for messages that are not from a list of preferred TLDs.

Important: This filter is not for everyone and you should adjust for best results considering your mail traffic and typical senders. You also should be familiar with editing plain text configuration files.1

Lets get started:

The local configuration for SpamAssassin is stored in this directory:

/Library/Server/Mail/Config/spamassassin

Within this directory, you can customize SpamAssassin with configuration files for filters, whitelists, blacklists, score overrides and more. These config files must end in .cf and are processed in alphabetical order. When the same setting is repeated, the last occurrence wins.

Your additions should load last, so we’ll call this new filter: z_tld.cf

Lets think about the goal.

We want to reduce spam, but still accept/deliver legitimate mail from these TLDs.
SpamAssassin runs hundreds of tests, and they all have a subtle effect on the final spam score.
We don’t want to be too heavy handed. For our example: we’re going to add 1.5 points to the final score.

Here’s our filter:

file: /Library/Server/Mail/Config/spamassassin/z_tld.cf

# add points if the From address is not a valid host in a listed TLD
header      LOCAL_FROM_TLD  From   !~ /@[a-z0-9\-\.]+\.(com|org|net|mil|edu)/i
describe    LOCAL_FROM_TLD         From address is not a valid host in a listed TLD
score       LOCAL_FROM_TLD  1.5

Lets break it down:

header:
This is the meat of the filter. We are searching the From header for mail not !~ matching the regex expression. The regex expression has two parts.

Part 1: /@[a-z0-9\-\.]+\. catches a legit hostname (mail.company) without the TLD (com, org, etc). spammer@spam!domain.com would be caught because ! is not allowed in a hostmame.

Part 2: (com|org|net|mil|edu) is the list of TLDs we do not penalize. Edit this list to include any TLD you typically receive mail from. Note: the filter ends in /i. A spamassassin expression begins with / ends with / and the i means case insensitive.

describe:
Description of the filter

score:
We are adding 1.5 points.
Remember, this is a negative match !~, so we add 1.5 points when the TLD is not com|org|net|mil|edu.

Shortcut

If you decide to implement this ‘as-is’, copy/paste the following in Terminal:

echo '# TLD Filter
# adds points if the From address is not a valid host in a listed TLD
header      LOCAL_FROM_TLD  From   !~ /@[a-z0-9\-\.]+\.(com|org|net|mil|edu)/i
describe    LOCAL_FROM_TLD         From address is not a valid host in a listed TLD
score       LOCAL_FROM_TLD  1.5' | sudo tee -a /Library/Server/Mail/Config/spamassassin/z_tld.cf

sudo launchctl stop org.amavis.amavisd
Test and Verify Results

Test your mail system, make sure you are able to send/receive.

Watch the amavis log located at /Library/Logs/Mail/amavis.log and you should see hits.

From your mail application, check for the x-spam-status header.

Check if syntax, typos or other errors in this filter have caused any errors:

sudo -u _amavisd -H spamassassin --lint -D 2>&1 | grep LOCAL_FROM_TLD

Reference

http://commons.oreilly.com/wiki/index.php/SpamAssassin/SpamAssassin_Rules

Document Version 1.0, 11.2.2016


  1. If you are unsure about how to edit a configuration file, have a look at our tutorial on how to edit text configuration files on OS X Server 

Is My Server Running in Performance Mode?

In the earlier days (up to OS X Lion 10.7), Server Admin had an option to “Dedicate system resources for high performance services”.

This option is no longer available in the GUI, but it still exists on the command-line.

NOTE: If you are using OS X 10.11 El Capitan or greater, you will need to disable SIP (System Integrity Protection) first.

Check if your server is running in performance mode with

serverinfo --perfmode

If you find its NOT, its generally a good idea to enable it as performance mode tunes the system to run as a server.

You can do so by issuing:

serverinfo --setperfmode 1

When done, reboot.

How to Edit Text Configuration Files on OS X Server

Managing OS X Server, quite often requires one to manually edit text based configuration files. As do many of our tutorials and FAQs.

There are many ways of doing this. You can use a Terminal based editor or one with a fancy GUI. What is paramount though, is that you use a Plain Text Editor like TextWrangler, Textastic or BBEdit. Rich Text Editors like Microsoft Word or Pages can severely damage your configuration files. Keeping above in mind, the rest comes down to personal preference.

On OS X I prefer to either use PICO, a Terminal based editor or TextWrangler which has a simple but powerful GUI and good syntax highlighting.

On iOS, PICO – accessed through an SSH session with Prompt – or TextWrangler with its built in SFTP client are my tools of choice.

Whether I use a Terminal based editor or one with a GUI mainly depends on the task at hand. For quick edits of a few lines, PICO works well and is the fastest way to go. If I need to make lots of changes or need a good overview of the file I am editing, a GUI editor is way more comfortable.

Let’s have a quick look at how these work.

Assuming we want to modify Postfix’ main.cf, we would issue:

sudo pico /Library/Server/Mail/Config/postfix/main.cf

And be presented with a view like this:

Now we can use our cursor keys to move around, the backspace key to delete characters or simply type what we need. When we are done editing, we need to save and exit. The commands for this are at the bottom of the window.

In order to save and exit, we would hit CTRL-O (to write the file) and CTRL-X to exit PICO. Alternatively we can just hit CTRL-X and enter y when asked to save.

Have a good look at the available commands as there are more options like cutting text and page scrolling.

While it may need a bit of time to get adjusted to, mastering a Terminal based text editor can be a very useful item in your tool chest.

Using the GUI instead of Terminal

If you don’t like using Terminal, you can always use a Plain Text Editor like TextWrangler which would look something like this

and behave like any other GUI Plain Text Editor.
The choice is yours, just make sure you avoid Rich Text Editors like Microsoft Word or Pages. There are plenty to choose from, like TextWrangler, Textastic, BBEdit, SubEthaEdit, SublimeText and many more. The choice on iOS is equally large.

For this tutorial, let’s look at TextWrangler which is a powerful (yet free) plain text editor

TextWrangler allows you to navigate hidden directories (/etc /Library etc) and edit files even when they are owned by root.

IMPORTANT: Don’t use the App Store version
Due to app store rules, the version from the app store is not able to unlock/edit files.
Download the application directly from the publisher: http://www.barebones.com/products/textwrangler/

These steps walk you through editing a hidden/privileged (root) file. We’ll use /etc/php.ini as our example.

In TextWrangler, use the Open File by Name option in the File menu.
This allows you to simply paste the path/name: /etc/php.ini

OpenByName

Another way to open /etc/php.ini is with the more familiar Open Dialog from TextWrangler.
Be sure to choose the Show Hidden Files option.

open-dialog

ALWAYS backup a file before you make changes
Save a backup to your Desktop using the Save a Copy option from the File menu.
Because the file is owned by root, you’ll need to authenticate.

Screen Shot 2016-02-10 at 11.45.44 AM

We need to be careful editing this file, one out of place character could effect your system.
You did backup first, right ?

Let’s make a safe change.
In the php.ini file, comments start with a semi-colon.
Simply add a space at the end of one of the commented lines:

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;  <<--- add a space at the end of this line
;;;;;;;;;;;;;;;;;;;

When you attempt to edit the file, you’ll be asked to authenticate again.
Once you authenticate, you can edit, then save the file.

That is all there is. Happy editing!

How to copy (bcc) all mail from specific senders to another address

Sender BCC Maps allow you to specify one or more senders along with a bcc_recipient address.
When an incoming or outgoing message matches sender_bcc_maps, the message is BCCd to the specified address

A few examples
  • BCC all mail sent from a fax or copier to a Fax/Copier archive
  • Bob wants all mail he sends from his 3 company addresses copied to his AOL account
  • Audit mail from a specific address

Create the sender_bcc file

Here is how I would create the file using pico.
note: when done editing with pico, hit ctrl-x to exit and y to save

sudo pico /Library/Server/Mail/Config/postfix/sender_bcc

Then you can start entering the following:

# sender-address [space(s)]  bcc-address
[email protected]    [email protected]
[email protected]    [email protected]

Alternatively you can use a plain text editor of your choice.

Run postmap anytime you edit the sender_bcc file

sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/postmap /Library/Server/Mail/Config/postfix/sender_bcc

Tell postfix where to find your new sender_bcc file then reload postfix

sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/postconf -e sender_bcc_maps=hash:/Library/Server/Mail/Config/postfix/sender_bcc
sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/postfix reload

To disable sender_bcc_maps

sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/postconf -e sender_bcc_maps=
sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/postfix reload