Configure E-mail settings in home LAN

Nextcloud version (eg, 29.0.5): 29.0.2
Operating system and version (eg, Ubuntu 29.04): Debian 12
Apache or nginx version (eg, Apache 2.4.25): 2.4.57-2
PHP version (eg, 8.3): 8.2+93+0~20230409.46+debian12~1.gbpdb4dcc

The issue you are facing:

Test mail is not sent after configuring SMTP settings.

Can’t find anything in log files. Not on mailserver and NC server.
Both servers can ping the other server.

Found this:

Is this still valid for NC 29.0.2?

Is this the first time you’ve seen this error? (Y/N): Yes. First time trying to configure.

Steps to replicate it:

  1. Install Postfix and sasldb2 on server M with snakeoil cert/key (later to be replaced with self signed) listening on port 587.
  2. Add to config.php: 'mail_smtpdebug' => true,
  3. In NC on server NC fill in e-mail details (SMTP,Non-STARTTLS,serverM:587,sasl user/pwd from server M)
  4. After clicking send test mail there is an red error like check settings and logs.

The output of your Nextcloud log in Admin > Logging:
Empty. There is a log file nextcloud.log in the data directory (not empty).
No occurrences of text: smtp.

Instead of postfix, I’d use something like this locally:

This smtp server (just for sending) can use an existing mail account to send mails out. In the past, I used ssmtp, but it is not maintained any more.

It can be done with Postfix, but you should probably set it up as a “satelite” aka Smarthost or Email Forwarder, that authenticates against an external SMTP server. Or if you’re running you own mail server locally, you may also send the emails directly to that server without authentication, depending on how that server is configured.

In Nextcloud you would then choose “Sendmode: sendmail” and add a “from address” that is authorized to send email from whatever smtp server/email account you have configured in Postfix.

Or you could use msmtp, as @tflidd suggested, which is way easier to setup.

Or you could not use a local mail transfer agent at all and use the SMTP option in Nextcloud to connect directly to an external smtp server or to your local mailserver. Of course, this option can only be used to send messages from Nextcloud, not for system messages.

Just don’t use postfix or any other “real” mail server, a misconfiguration and you risk to have an open mail server on the internet, with all the consequences. There are other solutions where this is technically not possible.

For running your own mail server, there are other communities for that.

Yeah, you definitely have a point there. :wink: However, after re-reading the original post, it might as well be that @arnoX’s actual goal is to connect Nextcloud to a self-hosted Postfix server which uses self-signed certificates, rather than setting up a mail forwarder on the Nextcloud host.

@arnoX If my assumtion is correct, try adding the following to the config.php of Nextcloud:

"mail_smtpstreamoptions" => array(
    'ssl' => array(
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false

See also here: Email — Nextcloud latest Administration Manual latest documentation

Correct. Postfix is configured to only serve my LAN.

Your setting is added to config.php.
After trying some more I discovered it is probably a misconfiguration of saslauthd in Postfix.
What the problem is I don’t know yet.
testsaslauthd on mailserver returns 0: OK "Success.".

Postfix was configured for localhost and not for local LAN.
Now that is solved and I received the test mail, I still have a last question:

Shouldn’t there be anything in logs on the NC server? Can’t find anything and nextcloud.log is more than a week old.