Sending emails - SMTP Configuration

Server configuration detail

Operating system: Linux 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64

Webserver: Apache/2.4.58 (Ubuntu) (apache2handler)

Database: mysql 10.11.8

PHP version: 8.3.6

Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, random, Reflection, SPL, session, standard, sodium, apache2handler, mysqlnd, PDO, xml, bcmath, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, imagick, intl, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, Zend OPcache

Nextcloud version: 31.0.0 - 31.0.0.18

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: unknown

Signing status

List of activated apps
Enabled:
 - activity: 4.0.0
 - app_api: 5.0.2
 - bruteforcesettings: 4.0.0
 - circles: 31.0.0-dev.0
 - comments: 1.21.0
 - contactsinteraction: 1.12.0
 - dashboard: 7.11.0
 - federation: 1.21.0
 - files_downloadlimit: 4.0.0
 - files_pdfviewer: 4.0.0
 - files_reminders: 1.4.0
 - files_sharing: 1.23.1
 - files_trashbin: 1.21.0
 - files_versions: 1.24.0
 - firstrunwizard: 4.0.0
 - logreader: 4.0.0
 - nextcloud_announcements: 3.0.0
 - notifications: 4.0.0
 - password_policy: 3.0.0
 - photos: 4.0.0-dev.1
 - privacy: 3.0.0
 - recommendations: 4.0.0
 - related_resources: 2.0.0
 - serverinfo: 3.0.0
 - sharebymail: 1.21.0
 - support: 3.0.0
 - survey_client: 3.0.0
 - systemtags: 1.21.1
 - text: 5.0.0
 - updatenotification: 1.21.0
 - user_status: 1.11.0
 - weather_status: 1.11.0
 - webhook_listeners: 1.2.0
Disabled:
 - admin_audit
 - encryption
 - files_external
 - suspicious_login
 - twofactor_nextcloud_notification
 - twofactor_totp
 - user_ldap
Configuration (config/config.php)
{
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "localhost",
        "cloud.ynwp.ca"
    ],
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "dbtype": "mysql",
    "version": "31.0.0.18",
    "overwrite.cli.url": "http:\/\/localhost",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbport": "",
    "dbtableprefix": "oc_",
    "mysql.utf8mb4": true,
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "installed": true,
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "defaultapp": "files",
    "mail_smtpmode": "smtp",
    "mail_sendmailmode": "smtp",
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpauth": true,
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "587"
}

Cron Configuration:

Mode: ajax Last: 2025-03-06T01:34:14+00:00 (245 seconds ago)

External storages: files_external is disabled

Encryption: no

User-backends:

  • OC\User\Database

Subscription:

  • No valid subscription key set

Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Setup checks

system
  • Errors in the log: 34 errors in the logs since February 26, 2025, 7:38:19 PM
  • Transactional File Locking: The database is used for transactional file locking. To enhance performance, please configure memcache, if available.
  • Maintenance window start: Server has no maintenance window start time configured. This means resource intensive daily background jobs will also be executed during your main usage time. We recommend to set it to a time of low usage, so users are less impacted by the load caused from these heavy tasks.
  • Memcache: No memory cache has been configured. To enhance performance, please configure a memcache, if available.
  • Mimetype migrations available: One or more mimetype migrations are available. Occasionally new mimetypes are added to better handle certain file types. Migrating the mimetypes take a long time on larger instances so this is not done automatically during upgrades. Use the command occ maintenance:repair --include-expensive to perform the migrations.
security
  • HTTP headers: Some headers are not set correctly on your instance
    • The Strict-Transport-Security HTTP header is not set (should be at least 15552000 seconds). For enhanced security, it is recommended to enable HSTS.
config
  • Default phone region: Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add “default_phone_region” with the respective ISO 3166-1 code of the region to your config file.
  • Email test: You have not set or verified your email server configuration, yet. Please head over to the “Basic settings” in order to set them. Afterwards, use the “Send email” button below the form to verify your settings.
php
  • PHP opcache: The PHP OPcache module is not properly configured. The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached, it is recommended to apply “opcache.interned_strings_buffer” to your PHP configuration with a value higher than “8”…
  • PHP Imagick module: The PHP module “imagick” in this instance has no SVG support. For better compatibility it is recommended to install it.

I have access to gmail and Office 365 for emails - I would like to setup a notification email that the Nextcloud will send when a new file is uploaded to the server.

Everything looks like it requires modern authentication now adays.

Is there anyway to make my Nextcloud server successfully send an email using with Gmail or Office 365?

Thanks!

Jim

You will need OAUTH to get access to Office 365 and Gmail.
You will need to configure in your Google account, that third party mail clients are allowed to access.

Ok…OAUTH…but it doesn’t seem like Nextcloud supports OAUTH. How do I configure Nextcloud to use OAUTH to send emails?

You can install Postfix and let Nextcloud send the mails from localhost. Then you don’t need authentication.

Yes and no. Yes, you can use Postfix or any other MTA instead of Nextcloud directly, but if you send the emails to Microsoft or Google without authentication, they will almost certainly be rejected. So you are simply shifting the authentication problem to the MTA. Not to mention that many VPS providers and ISPs are blocking outgoing port 25 by default.

But for me it works.

See administration manual:

1 Like

So you are sending emails directly from Postfix on your Nextcloud server, over port 25, to normal gmail.com or outlook.com addresses, and they end up in the inboxes of those addresses? :hushed:

No SMTP relay service or authentication involved? No need to whitelist the IP address of the sending server on the receiving side?

Never thought this would still work in 2025…

Yes, it works quite normally.

Unfortunately, these instructions are how to connect external applications/devices to your Nextcloud via OAUTH. I want Nextcloud to use OAUTH to connect to Office 365 to send emails.

Jim

I can’t believe it, but this worked. I installed Postfix and then tried a test email to my account at Office 365. It ended up in my Junk folder, but it worked.

I thought for sure it would get rejected.

Jim

2 Likes

Just whitelist it.

I did this a long time ago with a ProtonMail address to receive server notifications from a couple of VPSs I hosted at the time, and it actually worked. However, this is definitely not a viable solution if you need to receive email reliably.

And it’s even less viable for Nextcloud, unless you’re the only user, because the email account in the admin section is intended to reliably send notifications and password reset emails to all users on an instance, who probably all have their own email addresses associated with their accounts.

That’s right. But only as long as the mail server on the Nextcloud instance is not configured correctly.

You mean reverse DNS, DKIM, SPF and DMARC and everything else you need to deliver email reliably these days, which pretty much rules out all the people who host their Nextcloud instances at home from dynamic IP ranges… :wink:

Sure, you can use your own mail server, but it’s not as simple as running apt install postfix on your Nextcloud server. And most people will probably not go to the trouble of setting up their own mail server just to be able to send notifications from their Nextcloud. So if Nextcloud and a properly configured mail server are running on the same box, it’s more likely to be a mail server with a Nextcloud on it, not the other way around :wink:

1 Like