-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to connect with TLS encryption using STARTTLS 587 #17134
Comments
Do you maybe know what can cause the error? I tried the settings with thunderbird and it had no problem sending the email. |
Due to the fact that the STARTTLS command is sent but it couldn't initiate a TLS session, I would recommend to check if the certificate chain of the mail server can be verified by Nextcloud. |
@j-ed is there a console command i can use for that? |
is that it?
outputs this: CONNECTED(00000003)
|
Good that someone else had the same problem in the past 😉 |
@j-ed would you elaborate how there is a match with the other ticket? I saw that ticket before but didn't saw the connection or a solution for my case. I don't want to disabled the certificate verification, if thats the proposed solution. Using port 465 with STARTTLS didn't worked. As far as I know the solution with PHP or sendmail as the sendmode doesn't fit, since the mail server is not on the same machine as my Nextcloud instance. |
The mentioned ticked covered a connection problem on port 587 with STARTTLS and the status is closed, therefore my assumption was that it leads you into the right direction. What about the Nextcloud log file, could you fina any messages related to your send problem in it? Have you searched the Nextcloud help forum for a solution of your problem? I found e.g. the following positing covering a TLS problem. BTW, that is usually the right location to ask questions, this is only a bug tracker 😉 |
The Nextcloud log file is empty. And yes, I did search the forum before and the there mentioned tickets, where in the end most cases refer to a fix by Nextcloud 16 shipping Swiftmailer 6.1.3. If I remember correctly most of the tickets weren't claimed to be support ticket. That's why I used the issue ticket instead of the forum. I guess I'll try my luck there, if this issue doesn't qualify as one. |
I tested older Nextcloud (Docker) versions and my SMTP settings are working until Nextcloud 14.0.13-apache. 13.0.4 works 14.0.13-apache fails with:
|
it works for 14.0.13RC1-apache, too |
Connecting with Nextcloud 17 to smtp.goneo.de:587 works for me. |
That's weird, it doesn't work for me with Nextcloud Docker 17-apache, even though it's working with the same settings before 14.0.13-apache. |
@kesselb did you use encryption STARTTLS, too? Without encryption it works just fine, but I don't want to drop the encryption. |
@kesselb how did you setup Nextcloud? Also with the 17-apache Docker image? I still get the same error, even if I try fake credentials and clear the "From address" fields. |
Yes |
@kesselb would you share the (mail settings) of your config.php, which let to this error? My colleague tested the Docker 17-apache version and got the same error like me -.- |
|
Unfortunately I still get the my old error. |
Same here. Using Nexctloud 17.0.0 and the same SMTP settings work with other email clients. Only on nextcloud I get the : Unable to connect with TLS encryption Log data: ++ Starting Swift_SmtpTransport << 220 smtp7.infomaniak.ch ESMTP Infomaniak Network Relay Mail Servers; Sat, 5 Oct 2019 11:00:54 +0200 >> EHLO mycloud-integration.nostraterra.ch << 250-smtp7.infomaniak.ch Hello None.236.80.80.in-addr.arpa [80.80.236.11] (may be forged), pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-AUTH LOGIN PLAIN 250-STARTTLS 250-DELIVERBY 250 HELP >> STARTTLS << 220 2.0.0 Ready to start TLS !! Unable to connect with TLS encryption (code: 0)) very puzzling.. |
@guillaumv did you check, if it works on earlier Versions? |
Nextcloud 14 => Swiftmailer v6.0.2 https://github.com/swiftmailer/swiftmailer/blob/master/CHANGES maybe one of these changes broke it. Still need to figure out if this is related to nextcloud or swiftmailer. |
No luck still? |
@JLueke No I havent tried with earlier version than 16.3.5 and 17 (same error on both but I havent got the time to test much so far) I got this solved with mail mail provider who simply told me to disable STARTTLS. I did and I can now send email with their SMTP. However I have to compromise on security for now I guess... |
I also have exactly the same problem however it only happens with smtp.goneo.de. I've tried the same with an address from web.de, nextcloud is able to send emails via their smtp servers. My humble opinion would be, some server side configuration on smtp.goneo.de upsets nextcloud... |
I'm still stuck with the only university mail server I can use... |
Problem is on the server side, certificates that are used for SSL/TLS are not trusted or cert chain is bad (I've added all my certs into appropriate stores, openssl test is OK, but this doesn't help). Not the happiest solution, but you should add That line should be between lines 260 and 270 in Mailer.php (mine was on 262). Tested on NextCloud17.0.3.1, Apache 2.4.38, Debian 10. |
For me this solution worked only adding this parameter in the config.php file
For Nextcloud 18 on Ubuntu 18 connected to Exchange 2016 email server. |
I have the same problem and the solution of vindic is working for me to. But: i have a working mail server with trusted certificates (letsencrypt). The postfix server is configured to only use TLSv1.2. So, why do I have to use this workaround? |
tl;dr: Because the server you installed Nextcloud on does not trust the certificate that is used by your mail server. Nextcloud uses Swiftmailer (a library) to send emails. Swiftmailer (or PHP probably) uses the systems certificate storage for certificate validation.
If 1 works but 2 fails usually the server fails to validate the certificate. Why does it fail? The list of certificates contains only the big certificate companies. A reseller pays another certificate company for a intermediate certificate. With this intermediate certificate a reseller is able to sign certificates without being on the list (but the big companies are also using intermediates). Let's encrypt is also using a intermediate certificate. How to fix that: Make sure the server (Nextcloud is installed on) is able to establish a secure connection to the mail server. Please visit https://help.nextcloud.com/ or Stack Overflow for such questions. It's not really a issue with Nextcloud but the server configuration. Establishing connections to other services and validating certificates is something the operating system is responsible for. Nextcloud just logs the response. There is no way to fix that. |
Sorry for this miss placed question. I thought it would fit to the problem and it could be related with Nextcloud directly. Thanks, especially because of my wrong placement, for you detailed answer. Now i understand whats the problem. :-) |
This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions. |
same problem and For me this solution worked to only adding this parameter in the config.php file 'mail_smtpstreamoptions' => array ( 'ssl' => array ( 'allow_self_signed' => true, 'verify_peer' => false, 'verify_peer_name' => false ) ) For Nextcloud 20 on docker and synology server mail |
@pwepwe973 your solution is disabling the certificate validation though. See: https://www.php.net/manual/en/context.ssl.php for conext of each of those params. A better solution would be to update the cacerts on your distribution. On Debian based setups it would be something like sudo update-ca-certificates --fresh |
hello |
I've read through the thread and through the good explanation in post #17134 (comment), but as a non-technical hobbyist user I have to ask why Nextcloud is the only app that has this problem for me? Everywhere else I use my email server be it in webmail app or in android gmail app as ms exchange account or as smtp mailserver for all my local machines/vm it works without a hitch. Trying to use it in same way in NC or setup my mail server in NC mail app fails. I think understand why it happens and I can see the reason if I run I apologize if I misunderstand the problematics, but this is how I see it from what I can understand. |
Steps to reproduce
with STARTTLS 587 and required login credentials for authentication.
Expected behaviour
I receive a test mail.
Actual behaviour
With mail_smtpdebug enabled in the config I get following error message (domains are replaced like "mailprovider.de" as the server of the mail provider and "nextcloud.on.mydomain.com" for the nextcloud instance):
Beim Senden der E-Mail ist ein Problem aufgetreten. Bitte überprüfe Deine Einstellungen. (Fehler: Unable to connect with TLS encryption Log data: ++ Starting Swift_SmtpTransport << 220 smtp1.mailprovider.de ESMTP >> EHLO nextcloud.on.mydomain.com << 250-smtp1.mailprovider.de 250-PIPELINING 250-SIZE 51200000 250-ETRN 250-STARTTLS 250-AUTH PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN >> STARTTLS << 220 2.0.0 Ready to start TLS !! Unable to connect with TLS encryption (code: 0))
I only get the test mail if I use no encryption.
Server configuration detail
Operating system: Linux 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64
Webserver: Apache/2.4.38 (Debian) (apache2handler)
Database: mysql 5.7.24
PHP version:
7.3.9
Modules loaded: Core, date, libxml, openssl, pcre, sqlite3, zlib, ctype, curl, dom, fileinfo, filter, ftp, hash, iconv, json, mbstring, SPL, PDO, session, posix, Reflection, standard, SimpleXML, pdo_sqlite, Phar, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, apache2handler, apcu, exif, gd, imagick, intl, ldap, memcached, pcntl, pdo_mysql, pdo_pgsql, redis, sodium, zip, Zend OPcache
Nextcloud version: 16.0.4 - 16.0.4.1
Updated from an older Nextcloud/ownCloud or fresh install:
Where did you install Nextcloud from: Official Docker Image
Signing status
List of activated apps
Configuration (config/config.php)
Are you using external storage, if yes which one:
Are you using encryption:
Are you using an external user-backend, if yes which one:
Client configuration
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3338.0 Safari/537.36
Operating system: MAC OS
Logs
Web server error log
Nextcloud log
Browser log
POST https://nextcloud.on.mydomain.com/index.php/settings/admin/mailtest 400 (Bad request)
XHR failed loading: POST "https://nextcloud.on.mydomain.com/index.php/settings/admin/mailtest".
The text was updated successfully, but these errors were encountered: