Posts

AutoCreate/AutoSubscribe and Special-Use IMAP folders

Requirements
  • OS X 10.9.x Mavericks with Server 3.x
  • OS X 10.10.x Yosemite with Server 4.x or 5.x
  • OS X 10.11.x El Capitan with Server 5.x

For this article, we assume you are comfortable editing config files with Terminal or a suitable text editor.

Sever 3.x was the first version of OS X Server to include Dovecot 2.1.

Dovecot 2.1 added several new features, we will cover:

  • How to define folders which are automatically created, and optionally auto subscribed for all imap users.
    This useful feature allows you to define a core set of folders all users should have.
    Obvious examples are folders like Junk and Drafts, but it can be used to create folders for any use.

  • How to define Special-Use folders
    Modern email clients will ask the imap server which folder is preferred for Sent, Trash, Junk and Drafts.
    Defining these Special-Use folders helps keep the user experience consistent and predictable.

Before editing any file, be sure to back it up.

We’ll be working with just this one file:

/Library/Server/Mail/Config/dovecot/conf.d/15-mailboxes.conf

Here is a default copy of the file

##
## Mailbox definitions
##
## Version 2.2.x (AR14759611)

# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
namespace inbox {

  #mailbox name {
    # auto=create will automatically create this mailbox.
    # auto=subscribe will both create and subscribe to the mailbox.
    #auto = no

    # Space separated list of IMAP SPECIAL-USE attributes as specified by
    # RFC 6154: \All \Archive \Drafts \Flagged \Junk \Sent \Trash
    #special_use =
  #}

  # These mailboxes are widely used and could perhaps be created automatically:
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Trash {
    special_use = \Trash
  }

  # For \Sent mailboxes there are two widely used names. We'll mark both of
  # them as \Sent. User typically deletes one of them if duplicates are created.
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }

  # If you have a virtual "All messages" mailbox:
  #mailbox virtual/All {
  #  special_use = \All
  #}

  # If you have a virtual "Flagged" mailbox:
  #mailbox virtual/Flagged {
  #  special_use = \Flagged
  #}
}

Not much to it – its already commented with clear instructions

Lets look at the definition for Drafts.

mailbox Drafts {
    special_use = \Drafts
  }

If we want Drafts to be auto created, we would add auto=create and to have Drafts created and automatically subscribed instead use auto=subscribe.

This simple change will ensure everyone has a Drafts.

mailbox Drafts {
    auto=create
    special_use = \Drafts
  }

You can add any new folder

mailbox Important {
    auto=create
  }

When done editing, you’ll need to stop/start dovecot to activate the change.

sudo launchctl stop org.dovecot.dovecotd

It will restart automatically.

Why is apachectl not working on OS X Server 5.x?

With OS X Server 5 has introduced quite a few changes.

Once you install OS X Server 5 on Yosemite or El Capitan, the “desktop” version of Apache is taken over by a “server” version inside Server.app. To differentiate between the two and to take into account the different methods for stopping and starting Apache, a new command has been introduced with server-apachectl.

You can still use the same parameters. For example:

sudo server-apachectl graceful

sudo server-apachectl restart

Is spamtrainer compatible with OS X 10.11.x El Capitan and OS X Server 5.x?

Yes, starting with version 2.2.1, spamtrainer is compatible with OS X 10.11.x El Capitan and OS X Server 5.x.

Why do the web server logs show all connections as coming from 127.0.0.1?

If you looked at your web server logs after upgrading to OS X Server 5, you might have noticed that all connections seem to come from your localhost at 127.0.0.1 instead of the actual IP of the connecting user.

This is due to how OS X Server 5 implements virtual websites. Instead of exposing the sites directly, they are funnelled through a proxy (whether this is a good or a bad choice depends on your point of view).

To see the actual IPs of incoming connections to your web sites, either look at ‘/private/var/log/apache2/service_proxy_access.log’ or set up custom logging using ‘%a’ (don’t use ‘%h’ as it will resolve to the localhost).

Installing Gettext on OS X 10.11.X El Capitan

Before you get started, you need to make sure some basic requirements are met:

  • You have made a backup of your system.
  • You have the latest version of Apple’s Developer Tools (Xcode 7 or higher for 10.11.x including command line tools) installed. Dev Tools are available as a free download from the Mac App Store

First we need to download and compile gettext.

sudo -s

mkdir -p /topicdesk/sources

cd /topicdesk/sources

curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.6.tar.gz

tar xzf gettext-0.19.6.tar.gz

cd gettext-0.19.6

./configure --prefix=/usr/local/topicdesk

make

make install

Next we need to get download Apple’s version of PHP from http://www.opensource.apple.com in order to be able to build a dynamic library for PHP.

cd /topicdesk/sources

curl -O http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-101/php-5.5.30.tar.bz2

tar xjf php-5.5.30.tar.bz2

cd /topicdesk/sources/php-5.5.30/ext/gettext

phpize

./configure --prefix=/usr/local/topicdesk --with-gettext=/usr/local/topicdesk

make

make install

Unless you have disabled SIP, you will now see an error while the install script tries to move gettext.so into /usr/lib/php/extensions/no-debug-non-zts-20121212/
This is not a problem and can be solved by manually copying gettext.so to where we need it.

mkdir -p /usr/local/topicdesk/lib/php/extensions

cp -rp /topicdesk/sources/php-5.5.30/ext/gettext/modules/gettext.so /usr/local/topicdesk/lib/php/extensions

Now all we need to do is to modify our /etc/php.ini file and add:

extension=/usr/local/topicdesk/lib/php/extensions/gettext.so

When done, we need to make sure apache is restarted, by issuing:

server-apachectl graceful