TLS can't open secure connection to own mailserver

Hey I am getting this issue and its really bothering me

Jun 17 10:02:12 mail nextcloud[13127]: {"reqId":"O7tUtrMSPSEBkP0j2SSW","level":4,"time":"2020-06-17T09:02:12+00:00","remoteAddr":"2603:9000:b304:5210:11bd:7ca0:110e:d10b","user":"","app":"mail","method":"POST","url":"/index.php/apps/mail/api/accounts/1/send","message":"Sending mail failed: Could not send message: Could not open secure TLS connection to the server.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36","version":""}

Jun 17 10:02:12 mail nextcloud[13127]: {"reqId":"O7tUtrMSPSEBkP0j2SSW","level":3,"time":"2020-06-17T09:02:12+00:00","remoteAddr":"2603:9000:b304:5210:11bd:7ca0:110e:d10b","user":"","app":"mail","method":"POST","url":"/index.php/apps/mail/api/accounts/1/send","message":"{\"Exception\":\"OCA\\\\Mail\\\\Exception\\\\ServiceException\",\"Message\":\"Could not send message: Could not open secure TLS connection to the server.\",\"Code\":100,\"Trace\":[{\"file\":\"/var/www/nextcloud/apps/mail/lib/Controller/AccountsController.php\",\"line\":345,\"function\":\"sendMessage\",\"class\":\"OCA\\\\Mail\\\\Service\\\\MailTransmission\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Model\\\\NewMessageData\"},null,null,8]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":170,\"function\":\"send\",\"class\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\",\"type\":\"->\",\"args\":[1,\"sas\",\"asas\",\"\",\"\",\"\",false,8,null,null,[],null]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":99,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\"},\"send\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/App.php\",\"line\":125,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\"},\"send\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php\",\"line\":47,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\",\"args\":[\"OCA\\\\Mail\\\\Controller\\\\AccountsContrroller\",\"send\",{\"__class__\":\"OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer\"},{\"accountId\":\"1\",\"_route\":\"mail.accounts.send\"}]},{\"function\":\"__invoke\",\


dns settings

have you read the HOWTO carefully, esp. with the TLS-setup?

btw: if you’d post logs (very good!) it would be nice if you would mark them preformatted (</>) - usually they turn our more readable… i did that for you in your comment above.

Thank you for the quick reply.
I followed the settings verbatim… twice now lol If you want more logs or stuff I cant give it. I can create accounts but not send or receive mail. However the mail setting in basic settings works
does this mean anything

I’m sorry to be of no further help here… I just saw that errormessage when reformatting your Log. And directly above was some hint about TLS.

As the original thread was a HOWTO only, I just moved your problem to a new thread…

Usually the forum would ask for more info about your setup… but as this is not really a mail-forum but a nextcloud-forum… you decide yourself :wink: But be sure the more info anyone would have about your problematic instance the better :wink:

maybe you could search the forum though for threads that handle problematic TLS-connections - and maybe there will be a hint that would get you further.

good luck

I vaguely remember having this error as well, but I don’t remember the cause or solution, but I fixed it somehow. The mail app should not use TLS at all, because it is connecting over the loopback device (localhost).

To check which mail server settings the mail app is using post one of the following:

  • go to the mail app of the affected user and post a screenshot of the settings. To get there: Go to the mail tab and click the three dots right of the account name and choose edit.
  • go to your nextcloud database and post the contents of the oc_mail_accounts table for the affected user.
1 Like

You need a correct MX entry for incoming mails.

not correct: mail is handled by 10 mail.

set it to:

There is indeed an error in the MX configuration, but the DNS record should be still mail and not but it also should not be mail., so no period at the end. It is not clear how you configure your DNS so the tool might do some erroneous auto correct.

all users are affected unfortunatly

I used this tutorial and I am on a raspberry pi 4

host has address has IPv6 address 2603:9000:b304:5210:6614:54b7:443:9f7c mail is handled by 10 mail is handled by 10 webmail.

Why are you reading emails?
The mail setting is still broken.

Look settings e.g. Nextcloud GmbH:

host has address has IPv6 address 2a01:4f9:2b:29dc::153 mail is handled by 10

I suggest you first ensure that regular e-mail transmission is working properly before you use the mail app in Nextcloud. webmail. is wrong, there is not such domain. It means that your mail is served by the internet host that is literally reachable by webmail, without any top-level domain.

You deviated from the DNS configuration, I suggested in the tutorial. Try to replicate that first, then add your changes.

What you have to understand is that when you enter webmail in your DNS configuration it will be translated to because it is relative to the “main” domain. If you enter webmail. it will be interpreted as literally webmail without using your “main” domain. This is why your DNS is using the literal webmail as a MX host.

First off thank you guys so much this has been driving me crazy and I really appreciate the help. Ok so as for the DNS thing I dont know how to fix it, I am using go daddy and on there website I have just put in webmail but when you search it up it is webmail. which is really anoying. second off I can send emails with the test thing on in the setting using with no issues. If you guys have some commands I could use to test it I would be most grateful. Honestly I know I am being an idiot some how, I am a game designer not at all a server specialist or IT. Either way thanks :slight_smile:

I know you guys want me to figgure this out to some extent on my own but I have tried everything I can think of and googled all over :confused:

I found something but I am too dumb to understand

Ok so I found out in the error messages remoteAddr is but my pi is would thake make a diffrence?

And what about this

You should contact Go Daddy support or read their help on how to configure MX records properly. This is the main issue AFAICS, sending e-mails via Nextcloud does not need this record, therefore it works without it.

I just left go daddy and instantly most things worked I am so close I can tast it just one more problem to fix