Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL: Handshake timed out

Nextcloud version : 28.0.2
Operating system and version : 22.0.4 LTS
Apache or nginx version : 2.4.52
PHP version : 8.2

Hello everyone, I configured my smtp mail server and when I test sending emails I get the error below. I can’t figure out why sending doesn’t work on Nexcloud, also because I have other applications on the same machine that work with the same mail configuration. Can anyone give me some advice on this? Thanks

The issue you are facing:

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

The output of your Nextcloud log in Admin > Logging:

TransportException
Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL: Handshake timed out
Sending mail to "Array ( [destination.address@domain.it] => myadminuser ) " with subject “Prova impostazioni email” failed

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

<?php
$CONFIG = array (
  'instanceid' => 'oc6ae5zrjpgh',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'ip machine',
    1 => 'nextcloud-test.mydomain.com',
  ),
  'trusted_proxies' =>
  array (
    0 => 'ip proxy',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '28.0.2.5',
  'overwrite.cli.url' => 'http://nextcloud.mydomain/nextcloud',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'myuserdb',
  'dbpassword' => 'mypassdb',
  'installed' => true,
  'theme' => '',
  'loglevel' => 0,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'maintenance' => false,
  'trashbin_retention_obligation' => '5, 7',
  'versions_retention_obligation' => 'disabled',
  'maintenance_window_start' => 1,
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' =>
  array (
    0 => 'Group 1',
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
    0 => 'administrator',
    1 => 'Group 2',
  ),
  'mail_from_address' => 'mynameaddress.it',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'domain.com',
  'mail_smtphost' => 'name.domnet.ch',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 0,
  'mail_smtpstreamoptions' =>
  array (
    'ssl' =>
    array (
      'allow_self_signed' => true,
      'verify_peer' => false,
      'verify_peer_name' => false,
    ),
  ),
 );

The output of your Apache/nginx/system log in /var/log/____:
There are no Apache logs that relate to this issue.

{"reqId":"Qo9JKlZTTkFg0por1Qg8","level":0,"time":"2024-11-05T11:29:11+00:00","remoteAddr":"ip proxy","user":"myadminuser","app":"core","method":"POST","url":"/nextcloud/index.php/settings/admin/mailtest","message":"Sending mail to \"Array\n(\n    [destination.address@domain.it] => myadminuser\n)\n\" with subject \"Prova impostazioni email\" failed","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36","version":"28.0.2.5","exception":{"Exception":"Symfony\\Component\\Mailer\\Exception\\TransportException","Message":"Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL: Handshake timed out","Code":0,"Trace":[{"function":"Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\{closure}","class":"Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\SocketStream","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/Smtp/Stream/SocketStream.php","line":174,"function":"stream_socket_enable_crypto"},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/Smtp/EsmtpTransport.php","line":115,"function":"startTLS","class":"Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\SocketStream","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php","line":253,"function":"doHeloCommand","class":"Symfony\\Component\\Mailer\\Transport\\Smtp\\EsmtpTransport","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php","line":194,"function":"start","class":"Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/AbstractTransport.php","line":72,"function":"doSend","class":"Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php","line":136,"function":"send","class":"Symfony\\Component\\Mailer\\Transport\\AbstractTransport","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/mailer/Mailer.php","line":45,"function":"send","class":"Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport","type":"->"},{"file":"/var/www/nextcloud/lib/private/Mail/Mailer.php","line":196,"function":"send","class":"Symfony\\Component\\Mailer\\Mailer","type":"->"},{"file":"/var/www/nextcloud/apps/settings/lib/Controller/MailSettingsController.php","line":168,"function":"send","class":"OC\\Mail\\Mailer","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"sendTestMail","class":"OCA\\Settings\\Controller\\MailSettingsController","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":39,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/3rdparty/symfony/mailer/Transport/Smtp/Stream/SocketStream.php","Line":171,"message":"Sending mail to \"Array\n(\n    [destination.address@domain.it] => myadminuser\n)\n\" with subject \"Prova impostazioni email\" failed","exception":{},"CustomMessage":"Sending mail to \"Array\n(\n    [destination.address@domain.it] => myadminuser\n)\n\" with subject \"Prova impostazioni email\" failed"}}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.