Use roundcube with an external mail provider

Hi,

I trust YunoHost but not myself, so I prefer to let a specialized company handle my emails.

I want to use a webmail, installed through YunoHost though. I chose roundcube because my provider does not support THREAD/SORT imap extensions and roundcube is able to do it by itself.

The only issue being that the roundcube package for YunoHost only allows to use the local imap configuration.

I managed to bypass it by editing the configuration, forcing an imap server and disabling two plugins (http authentication and password - which is used to edit a LDAP password for ex.).
This post is here to kind of document it, in case anyone else would be interested.

The configuration file will be rewritten on each app upgrade so I used a hook to set it back:

mkdir -p /etc/yunohost/hooks.d/post_app_upgrade/
nano /etc/yunohost/hooks.d/post_app_upgrade/01-roundcube-custom-config

Then paste this:

#!/bin/bash

source /usr/share/yunohost/helpers

if [[ "$YNH_APP_ID" == "roundcube" ]]; then
        CONFIG_FILE="/var/www/${YNH_APP_INSTANCE_NAME}/config/config.inc.php"
        echo '
// Custom config
$config["imap_host"] = "ssl://REPLACE_IMAP.DOMAIN.TLD:993";
$pluginIndex = array_search("http_authentication", $config["plugins"]);
if ($pluginIndex !== false) {
        unset($config["plugins"][$pluginIndex]);
}

$pluginIndex = array_search("password", $config["plugins"]);
if ($pluginIndex !== false) {
        unset($config["plugins"][$pluginIndex]);
}
' >> "${CONFIG_FILE}"
fi

You might need to logout if there is an error, then log-in with your imap credentials.