Mails not getting sent (unverifiable sender)

Nextcloud version (eg, 12.0.2): 16.0.3
Operating system and version (eg, Ubuntu 17.04): Debian 9
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.14.2
PHP version (eg, 7.1): 7.3.6 FPM

The issue you are facing:
Trying to set up mail notifications by Nextcloud; entered SMTP mode, STARTTLS, FROM-address, Login mode (plain or LOGIN), server address and port and the credentials under Settings → basic settings. Upon hitting the “SEND EMAIL” button NC reports

A problem occurred while sending the email. Please revise your settings. (Error: Expected response code 354 but got code “554”, with message “554 5.7.1 : Data command rejected: Unverifiable sender.”)

The output of your Nextcloud log in Admin > Logging:

Nothing about mail in there :confused: - just about missing ACPu (but this I’ll have to fix separately)

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'trusted_domains' => 
  array (
    0 => 'cloud.FQDN',
    1 => 'REDACTED',
    2 => '192.168.178.XX',
  ),
  'datadirectory' => '/REDACTED/nextcloud-data',
  'overwrite.cli.url' => 'https://REDACTED',
  'dbtype' => 'mysql',
  'version' => '16.0.3.0',
  'dbname' => 'REDACTED',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'REDACTED',
  'dbpassword' => 'REDACTED',
  'logtimezone' => 'UTC',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => 'REDACTED',
  'mail_domain' => 'REDACTED',
  'mail_smtphost' => 'REDACTED',
  'mail_smtpport' => '587',
  "mail_smtpdebug" => true,
  'theme' => '',
  'loglevel' => 0,
  'maintenance' => false,
  'appstore.experimental.enabled' => true,
  'debug' => false,
  'session_lifetime' => 86400,
  'session_keepalive' => true,
  'mail_smtpsecure' => 'tls',
  'data-fingerprint' => '0705c71a39312c40f63b443be7c2ea90',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'USERNAME',
  'mail_smtppassword' => 'REDACTED',
  'mysql.utf8mb4' => true,
  'app_install_overwrite' => 
  array (
    0 => 'spreed',
  ),
  'updater.secret' => 'REDACTED',
  'mail_smtpauthtype' => 'PLAIN',

The output of your Apache/nginx/system log in /var/log/____:

**Nginx:**
XX.XX.XX.XX - - [10/Jul/2019:12:52:34 +0200] "POST /settings/admin/mailtest HTTP/2.0" 400 225 "https://FQDN/settings/admin" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/75.0.3770.90 Chrome/75.0.3770.90 Safari/537.36"

**Postfix:**
Jul 10 12:54:23 REDACTED postfix/submission/smtpd[50274]: connect from mue-XX-XX-XX-XX.dsl.tropolys.de[XX.XX.XX.XX]
Jul 10 12:54:23 REDACTED postfix/submission/smtpd[50274]: Anonymous TLS connection established from mue-XX.XX.XX.XX.dsl.tropolys.de[XX.XX.XX.XX]: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
Jul 10 12:54:23 REDACTED postfix/submission/smtpd[50274]: 5F3B25C3C9D4: client=mue-XX-XX-XX-XX.dsl.tropolys.de[XX.XX.XX.XX], sasl_method=PLAIN, sasl_username=USERNAME
Jul 10 12:54:23 REDACTED postfix/submission/smtpd[50274]: 5F3B25C3C9D4: reject: DATA from mue-XX-XX-XX-XX.dsl.tropolys.de[XX.XX.XX.XX]: 554 5.7.1 <DATA>: Data command rejected: Unverifiable sender.; from=<USERNAME@FQDN> to=<USERNAME@FQDN> proto=ESMTP helo=<cloud.FQDN>
Jul 10 12:54:23 REDACTED postfix/submission/smtpd[50274]: disconnect from mue-XX-XX-XX-XX.dsl.tropolys.de[XX.XX.XX.XX] ehlo=2 starttls=1 auth=1 mail=1 rcpt=1 data=0/1 quit=1 commands=7/8

The postfix is a working setup (running Kolab on that server, DynDNSsed IP with port forwardings to pass my DSL router) that is otherwise reliably working for years now.

Any hints what may be going wrong here? I wasn’t able to pinpoint it so far …

The reported problem has most likely nothing to do with Nextcloud and is a problem of your email configuration. You should make sure that you’re sending your email using a smart host and not directly because most of the email servers aren’t excepting email which is send directly from a DynDNS server. Otherwise the email sender cannot be verified.