Mail App - Unable to Send Email

Hello All,

This was working for a few weeks. I am not sure what I or an automatic update did to break this feature. I can get email and view it, I just cannot send.
Things I have tried:
I have tried updating Nextcloud and the Mail app, but it did not help.
I have tried upgrading PHP from 7.4 to 8.1 on Ubuntu 20.04, did not help.
I have tried removing Mail app and re-installing it, did not help.
I tried running the HanssonIT scripts for upgrading Nextcloud, did not help
I ran the HannsonIT pre-built Nextcloud VM to see if it is an issue with my Exchange server or TLS config, it was able to send emails perfectly. So I know that the configuration on my Email server did not change, if at all.

Based on the error, it sounds like it is a configuration issue on the PHP side, but I don’t know. I cannot find the correct keywords for a Google search. Any help is much appreciated.

[mail] Warning: Could not send outbox message 2: Could not send message: mail() returned failure.

at 2022-05-12T08:50:01-06:00

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

[/details]

Nextcloud version (eg, 20.0.5): 23.0.3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.41
PHP version (eg, 7.4): 7.4.3

The issue you are facing: Unable to send email from Mail app

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. I attempt to send an email. Reply, Forward, or New all result in “Unable to send email”

The output of your Nextcloud log in Admin > Logging:

{"reqId":"4GVLpqm92bgqVItTnSRD","level":2,"time":"2022-05-12T10:55:02-06:00","remoteAddr":"","user":"--","app":"mail","method":"","url":"--","message":"Could not send outbox message 3: Could not send message: mail() returned failure.","userAgent":"--","version":"23.0.3.2","exception":{"Exception":"OCA\\Mail\\Exception\\ServiceException","Message":"Could not send message: mail() returned failure.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php","line":271,"function":"sendMessage","class":"OCA\\Mail\\Service\\MailTransmission","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php","line":129,"function":"sendLocalMessage","class":"OCA\\Mail\\Service\\MailTransmission","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php","line":196,"function":"sendMessage","class":"OCA\\Mail\\Service\\OutboxService","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/OutboxWorkerJob.php","line":55,"function":"flush","class":"OCA\\Mail\\Service\\OutboxService","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Mail\\BackgroundJob\\OutboxWorkerJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":150,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php","Line":210,"Previous":{"Exception":"Horde_Mime_Exception","Message":"mail() returned failure.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Mail.php","line":479,"function":"send","class":"Horde_Mime_Part","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php","line":208,"function":"send","class":"Horde_Mime_Mail","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php","line":271,"function":"sendMessage","class":"OCA\\Mail\\Service\\MailTransmission","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php","line":129,"function":"sendLocalMessage","class":"OCA\\Mail\\Service\\MailTransmission","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php","line":196,"function":"sendMessage","class":"OCA\\Mail\\Service\\OutboxService","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/OutboxWorkerJob.php","line":55,"function":"flush","class":"OCA\\Mail\\Service\\OutboxService","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Mail\\BackgroundJob\\OutboxWorkerJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":150,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Part.php","Line":1642,"Previous":{"Exception":"Horde_Mail_Exception","Message":"mail() returned failure.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Part.php","line":1620,"function":"send","class":"Horde_Mail_Transport_Mail","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Mail.php","line":479,"function":"send","class":"Horde_Mime_Part","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php","line":208,"function":"send","class":"Horde_Mime_Mail","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php","line":271,"function":"sendMessage","class":"OCA\\Mail\\Service\\MailTransmission","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php","line":129,"function":"sendLocalMessage","class":"OCA\\Mail\\Service\\MailTransmission","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php","line":196,"function":"sendMessage","class":"OCA\\Mail\\Service\\OutboxService","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/OutboxWorkerJob.php","line":55,"function":"flush","class":"OCA\\Mail\\Service\\OutboxService","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Mail\\BackgroundJob\\OutboxWorkerJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":150,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mail/Horde/Mail/Transport/Mail.php","Line":111}},"CustomMessage":"Could not send outbox message 3: Could not send message: mail() returned failure."},"id":"627d40ed1cedb"}

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

<?php
$CONFIG = array (
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '',
    2 => '',
    3 => '',
    4 => '',
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '23.0.3.2',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'instanceid' => '',
  'upgrade.disable-web' => true,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => '2',
  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => '',
    ),
  ),
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => '604800',
  'log_rotate_size' => '0',
  'trashbin_retention_obligation' => 'auto, 60',
  'versions_retention_obligation' => 'auto, 180',
  'activity_expire_days' => '120',
  'simpleSignUpLink.shown' => false,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.5,
    'dbindex' => 0,
    'password' => '',
  ),
  'default_phone_region' => 'us',
  'logtimezone' => 'America',
  'htaccess.RewriteBase' => '/',
  'session_lifetime' => '604800',
  'enable_previews' => true,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\BMP',
    4 => 'OC\\Preview\\MarkDown',
    5 => 'OC\\Preview\\MP3',
    6 => 'OC\\Preview\\TXT',
    7 => 'OC\\Preview\\Movie',
    8 => 'OC\\Preview\\Photoshop',
    9 => 'OC\\Preview\\SVG',
    10 => 'OC\\Preview\\TIFF',
  ),
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
  ),
  'maintenance' => false,
  'app_install_overwrite' => 
  array (
    0 => 'files_trackdownloads',
    1 => 'files_clipboard',
    2 => 'pdfdraw',
    3 => 'whiteboard',
    4 => 'auto_mail_accounts',
    5 => 'nextbackup',
    6 => 'pdfannotate',
    7 => 'integration_whiteboard',
    8 => 'ldap_write_support',
    9 => 'ldapcontacts',
    10 => 'ldap_contacts_backend',
    11 => 'customproperties',
  ),
  'mail_from_address' => '',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '',
  'mail_smtphost' => '',
  'allow_local_remote_servers' => 'true',
  'app.mail.verify-tls-peer' => 'false',
  'app.mail.transport' => 'php-mail',
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
    0 => '',
    1 => '',
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
    0 => '',
  ),
);

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

172.16.31.229 - - [12/May/2022:08:50:09 -0600] "GET /apps/mail/api/messages?mailboxId=764&limit=20 HTTP/2.0" 412 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:09 -0600] "POST /apps/mail/api/mailboxes/786/sync HTTP/2.0" 412 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:12 -0600] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/2.0" 304 167 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:01 -0600] "GET /apps/logreader/poll?lastReqId=ugTRYMTAoAYhqWopMxIv HTTP/2.0" 200 717 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:26 -0600] "GET /apps/mail/api/outbox HTTP/2.0" 412 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:41 -0600] "GET /apps/mail/api/messages?mailboxId=764&limit=20 HTTP/2.0" 412 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:41 -0600] "POST /apps/mail/api/mailboxes/786/sync HTTP/2.0" 412 706 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:41 -0600] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/2.0" 304 167 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:22 -0600] "GET /apps/logreader/poll?lastReqId=ugTRYMTAoAYhqWopMxIv HTTP/2.0" 200 717 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
172.16.31.229 - - [12/May/2022:08:50:42 -0600] "GET /apps/logreader/poll?lastReqId=ugTRYMTAoAYhqWopMxIv HTTP/2.0" 200 717 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

Nothing relevant to this issue. Just authentication attempts.