Mail app sending email but not moving it to sent folder and reporting mail server error

Nextcloud version (eg, 29.0.5): 29.0.7snap
Operating system and version (eg, Ubuntu 24.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): nginx, I think
PHP version (eg, 8.3): 8.1.2

The issue you are facing:

I am having trouble sending emails using Nextcloud’s mail app when the email has an attachment. Nextcloud mail tells me that it could not send the message with a Server Error. But the message actually sends. I know this because if I send an email with attachment to myself, it arrives in my inbox despite Nextcloud mail app telling me it did not send. It appears the email just doesn’t get placed in the sent folder because of some miscommunication between the SMTP server and Nextcloud. I have the mail app properly configured to place messages in the Sent folder. If the email does not have an attachment, Nextcloud mail sends without issue. I am using the iCloud SMTP server. I do not have this issue using Thunderbird or other email clients.

I have set the config.php file using the recommendations in this community (as per below) but they have not resolved the issue:
‘mail_smtpstreamoptions’ =>
array (
‘ssl’ =>
array (
‘allow_self_signed’ => true,
‘verify_peer’ => false,
‘verify_peer_name’ => false,
),
),

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

Steps to replicate it:

  1. Configure Nextcloud mail for an iCloud account
  2. Send email with an attachment

The output of your Nextcloud log in Admin > Logging:

Nothing

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

Nothing

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

Nothing

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

Still having issues with sending mail. I configured the Mail app to use the gmail smtp server and I can sometimes successfully send an email with an attachment, but not every time. So far, my success rate is one out of four emails send and move to the sent folder.

Success is still defined as the email sending and moving to the sent folder. All emails send, but 3 out of 4 do not move to the sent folder and error out as mail server error.

What’s the actual error message?

What appears in your nextcloud.log?

Have you seen the Troubleshooting section of the Mail app README? It can be found here: mail/doc/admin.md at main · nextcloud/mail · GitHub