NextCloud is best known as an open source cloud storage server, but did you know it also offers apps such as NextCloud Calendar, Contacts, and Mail as a complete groupware solution? The Calendar and Contacts apps are CalDAV and CardDAV servers in their own right, while the Mail app is a webmail client which needs to be connected with an existing mail server, much like Mozilla Thunderbird or Microsoft Outlook. These apps can be used separately, or in conjunction with one another.
MailCow is an open source mail server that we highly recommend for enterprises of all sizes. Its self-hosted, which means you can use a cloud provider in the country of your choice, or host it on-premises in your own office or datacenter.
By default MailCow includes SOGo, a Material Design interface for webmail, but many of our end user organizations have also deployed NextCloud as part of their day-to-day workflow. Since their employees already use NextCloud for file sharing and collabration on a day-to-day basis, they prefer to integrate MailCow with NextCloud Mail for a completely unified experience similar to G Suite or Office 365.
If you are looking to roll out MailCow as a more secure & cost-effective alternative to commercial hosted email providers, it can be wise to undertake a NextCloud installation at the same time. While its possible to import calendars & contacts from MailCow to NextCloud at a later time, you will most likely want to standardize your workforce on a single solution from the beginning.
As a mail administrator, you should set a reasonable message size limit (e.g. 25 MB as is the case with Gmail) on your MailCow users to prevent your mail server from being overwhelmed by large attachments. Besides, storing documents & attachments on a mail server makes them very difficult to resurface later through the search functionality, especially as inboxes are deprovisioned as employees turn over in the organization.
NextCloud enables your users to send attachments of any size & share them with multiple recipients, without taking up valuable storage space on your mail server. It’s a lot more efficient than email attachmenets, since only one copy of the file needs to be stored between all of the users that have access to it.
Not only does NextCloud have its own official Mail app, but it also supports third-party webmail clients such as Rainloop and Afterlogic. Afterlogic is the best for composing HTML emails and its used by many large corporations & government agencies, but it requires setting up on a separate server and integrating it with NextCloud.
For the purpose of this article we will cover how to install the official Mail app in NextCloud, configure IMAP access to a MailCow inbox, and fix a problem with remote images not displaying – even after clicking to allow images in NextCloud 17.
1 – Open the Apps screen in the NextCloud administrator dashboard.
It can be accessed by selecting the dropdown from your profile image after signing into NextCloud, or at
/settings/apps following your NextCloud URL. Expand the search bar by clicking on the magnifying glass icon, type Mail, and press Enter/Return.
Click Download and enable besides the Mail app.
2 – Launch the NextCloud Mail app.
A new Mail icon will appear in the top navigation bar of your NextCloud dashboard. Click it to launch the Mail app. Since its your first time launching the app, you will be prompted to add a new IMAP email account.
This tutorial assumes you have already created the inbox from the MailCow administrator dashboard.
Name: An internal name you want to use to identify this inbox in NextCloud Mail.
Mail Address: The email address of the MailCow inbox (e.g. email@example.com)
IMAP Settings (Incoming Email)
IMAP Host: The address of your MailCow instance (e.g. mail.example.com)
IMAP Security: SSL/TLS
IMAP Port: 993
IMAP User: The email address of the MailCow inbox (e.g. firstname.lastname@example.org)
IMAP Password: The password corresponding to the MailCow inbox
SMTP Settings (Outgoing Email)
SMTP Host: The address of your MailCow instance (e.g. mail.example.com)
SMTP Security: STARTTLS
SMTP Port: 587
SMTP User: The email address of the MailCow inbox (e.g. email@example.com)
SMTP Password: The password corresponding to the MailCow inbox
Click Connect to confirm the connection, and create the inbox in NextCloud Mail.
3 – Fix an issue with loading remote images in emails.
Most modern emails rely on HTML and images loaded from a remote server to display correctly. To protect your privacy, NextCloud protects you from email trackers by replacing tracking pixels that are less than 5 by 5 pixels with a blank PNG (
blocked-image.png), and does not load any remote images until you click on the Show images from this sender button.
But NextCloud 17 (and 16) requires a patch to allow the images to display in the browser. The code for the NextCloud Mail app applies the CSS property display:none; to the remote images, making them blank in the browser even after the user has chosen to allow them.
SSH into your NextCloud server and apply the following change using a text editor. Use the
sudo -u option (as root) to edit the file as the web server and/or PHP-FPM user (e.g. apache, www-data, or nginx) to prevent permissions issues.
Comment out line 76, by adding a pound symbol to the beginning of the line:
$attr = $this->setDisplayNone($attr);
in the file
$nextcloud_dir is the local path to your NextCloud installation – typically
This disables the
setDisplayNone() function further down in the PHP file, which applies a
display:none; property to any images in the Mail client for whatever reason. This issue will likely be resolved in future versions of NextCloud, but applying this patch for now will make Mail work properly for all of the users across your NextCloud instance.
Disable then re-enable the Mail app from the Apps screen in the NextCloud dashboard, clear your browser cache, then refresh the Mail app to observe the change take effect. Now remote images will load when clicking Show images from this sender.