Swift_TransportException error spam - 40MB log file - how to disable Email features?

Nextcloud version: 23.0.0
Operating system and version: Docker 20.10.2 on Debian 5.10
Apache or nginx version: nginx 1.20.2
PHP version: 7.4.26

The issue you are facing:
As we only use a subset of Nextcloud’s features I didn’t connect it to a mail server. Today however I noticed that, since setting Nextcloud up, the log has been spammed with mail related errors - every 5 minutes. After googling I followed Nextcloud: Email komplett abstellen - Nextcloud/Owncloud - linuxmuster.net to disable email connections from my nextcloud instance however that flag doesn’t seem to do anything - the error still keeps getting printed.

Steps to replicate it:

  1. Setup Nextcloud without setting up a connection to a email server
  2. Wait a bit
  3. Every 5 minutes the same error gets logged twice

The output of your Nextcloud log in Admin > Logging:

{"reqId":"uPr4O1laPEL3hGZ1qFid","level":3,"time":"2022-04-28T14:30:02+00:00","remoteAddr":"","user":"--","app":"notifications","method":"","url":"--","message":"Connection could not be established with host 127.0.0.1 :stream_socket_client(): unable to connect to 127.0.0.1:25 (Connection refused)","userAgent":"--","version":"23.0.0.10","exception":{"Exception":"Swift_TransportException","Message":"Connection could not be established with host 127.0.0.1 :stream_socket_client(): unable to connect to 127.0.0.1:25 (Connection refused)","Code":0,"Trace":[{"function":"{closure}","class":"Swift_Transport_StreamBuffer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php","line":264,"function":"stream_socket_client"},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php","line":58,"function":"establishSocketConnection","class":"Swift_Transport_StreamBuffer","type":"->"},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php","line":143,"function":"initialize","class":"Swift_Transport_StreamBuffer","type":"->"},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php","line":65,"function":"start","class":"Swift_Transport_AbstractSmtpTransport","type":"->"},{"file":"/config/www/nextcloud/lib/private/Mail/Mailer.php","line":204,"function":"send","class":"Swift_Mailer","type":"->"},{"file":"/config/www/nextcloud/apps/notifications/lib/MailNotifications.php","line":215,"function":"send","class":"OC\\Mail\\Mailer","type":"->"},{"file":"/config/www/nextcloud/apps/notifications/lib/MailNotifications.php","line":166,"function":"sendEmailToUser","class":"OCA\\Notifications\\MailNotifications","type":"->"},{"file":"/config/www/nextcloud/apps/notifications/lib/BackgroundJob/SendNotificationMails.php","line":49,"function":"sendEmails","class":"OCA\\Notifications\\MailNotifications","type":"->"},{"file":"/config/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Notifications\\BackgroundJob\\SendNotificationMails","type":"->"},{"file":"/config/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":63,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/config/www/nextcloud/cron.php","line":128,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php","Line":261,"CustomMessage":"Connection could not be established with host 127.0.0.1 :stream_socket_client(): unable to connect to 127.0.0.1:25 (Connection refused)"},"id":"626aa8c4359bc"}

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

<?php
$CONFIG = array (
  'auth.webauthn.enabled' => 'false',
  'defaultapp' => 'deck',
  'default_language' => 'en',
  'default_phone_region' => 'DE',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'skeletondirectory' => '/skeleton',
  'enable_email' => 'false', /* To prevent Nextcloud from spamming due to it trying to connect to a non existent mail server */
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => '127.0.0.1',
    1 => 'REDACTED',
  ),
  'trusted_proxies' => ['REDACTED'],
  'dbtype' => 'mysql',
  'version' => '23.0.0.10',
  'overwritecondaddr' => '^REDACTED$',
  'overwrite.cli.url' => 'REDACTED',
  'dbname' => 'nextcloud',
  'dbhost' => 'mysql',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'overwriteprotocol' => 'https',
  'app_install_overwrite' => 
  array (
    0 => 'apporder',
  ),
);

This feature does not exist anymore. Set mail to sendmail and it should be silent.

Doesn’t help. The error, however, changes:

{"reqId":"JtlHa7WV9fIvXbHuFgp4","level":3,"time":"2022-04-28T17:35:02+00:00","remoteAddr":"","user":"--","app":"notifications","method":"","url":"--","message":"Expected response code 220 but got an empty response","userAgent":"--","version":"23.0.0.10","exception":{"Exception":"Swift_TransportException","Message":"Expected response code 220 but got an empty response","Code":0,"Trace":[{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php","line":360,"function":"assertResponseCode","class":"Swift_Transport_AbstractSmtpTransport","type":"->"},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php","line":147,"function":"readGreeting","class":"Swift_Transport_AbstractSmtpTransport","type":"->"},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php","line":50,"function":"start","class":"Swift_Transport_AbstractSmtpTransport","type":"->"},{"file":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php","line":65,"function":"start","class":"Swift_Transport_SendmailTransport","type":"->"},{"file":"/config/www/nextcloud/lib/private/Mail/Mailer.php","line":204,"function":"send","class":"Swift_Mailer","type":"->"},{"file":"/config/www/nextcloud/apps/notifications/lib/MailNotifications.php","line":215,"function":"send","class":"OC\\Mail\\Mailer","type":"->"},{"file":"/config/www/nextcloud/apps/notifications/lib/MailNotifications.php","line":166,"function":"sendEmailToUser","class":"OCA\\Notifications\\MailNotifications","type":"->"},{"file":"/config/www/nextcloud/apps/notifications/lib/BackgroundJob/SendNotificationMails.php","line":49,"function":"sendEmails","class":"OCA\\Notifications\\MailNotifications","type":"->"},{"file":"/config/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Notifications\\BackgroundJob\\SendNotificationMails","type":"->"},{"file":"/config/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":63,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/config/www/nextcloud/cron.php","line":128,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/config/www/nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php","Line":447,"CustomMessage":"Expected response code 220 but got an empty response"},"id":"626ad0467a9a4"}

I am also interested in disabling email feature.
Any luck with this problem?