Smtp config not working
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Smtp config not working

by
Gmalz
Created on 2024-12-01 11:34:49 (edited on 2024-12-02 08:21:57) in Email and office tools

Hi the community,

I have a problem on smtp configuration of application web Laravel. I have this error when I want to send email via a command line:

Symfony\Component\Mailer\Exception\TransportException

  Connection could not be established with host "ssl0.ovh.net:587": stream_socket_client(): Unable to connect to ssl0.ovh.net:587 (Connection refused)

  at vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php:154
    150$streamContext = stream_context_create($options);
    151152$timeout = $this->getTimeout();
    153set_error_handler(function ($type, $msg) {154throw new TransportException(sprintf('Connection could not be established with host "%s": ', $this->url).$msg);
    155});
    156try {
    157$this->stream = stream_socket_client($this->url, $errno, $errstr, $timeout, \STREAM_CLIENT_CONNECT, $streamContext);
    158} finally {

  1   [internal]:0
      Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream::Symfony\Component\Mailer\Transport\Smtp\Stream\{closure}("stream_socket_client(): Unable to connect to ssl0.ovh.net:587 (Connection refused)", "/home/ulydebp/rent-reminder/vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php")
      +13 vendor frames

  15  app/Console/Commands/TestSendEmailCommand.php:30
      Illuminate\Mail\PendingMail::send(Object(App\Mail\TestEmail))

I also tried to use Gmail's smtp, same result.

 

Here are the different configurations on the server:

  • pro hosting with PHP 8.2
  • application web with Laravel 11
  • my .env content:
MAIL_MAILER=smtp
MAIL_HOST=ssl0.ovh.net
MAIL_PORT=587
MAIL_USERNAME="EMAIL_DOMAIN"
MAIL_PASSWORD="PASSWORD_EMAIL_DOMAIN"
MAIL_ENCRYPTION=tls

I also called the support team, who unfortunately didn't help me any more than that. They sent me to this url https://help.ovhcloud.com/csm/fr-web-hosting-monitoring-automatic-emails?id=kb_article_view&sysparm_article=KB0052902#envoi-de-mails-a-laide-dun-script-smtp 

An idea of what I could do would be most welcome.

Thanks in advance


2 Replies ( Latest reply on 2024-12-06 10:27:33 by
fritz2cat 🇧🇪 🇪🇺
)

Hello @Gmalz ,
Hope you're fine, sorry for the late answer.

Currently you're using the ‘ssl0.ovh.net:587’ port when it should be ‘ssl0.ovh.net:465’.
Connecting via ‘ssl0.ovh.net:587’ could therefore generate an error during authentication.

If this does not correct the error, we recommend checking that the version of TLS used is 1.2 or 1.3 with one of the following cyphers:

# TLS 1.3 (suites in server-preferred order)

TLS_AES_256_GCM_SHA384 (0x1302) ECDH x25519 (eq. 3072 bits RSA) FS

256

TLS_CHACHA20_POLY1305_SHA256 (0x1303) ECDH x25519 (eq. 3072 bits RSA) FS

256P

TLS_AES_128_GCM_SHA256 (0x1301) ECDH x25519 (eq. 3072 bits RSA) FS

128

 

# TLS 1.2 (suites in server-preferred order)

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030) ECDH x25519 (eq. 3072 bits RSA) FS

256

TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca8) ECDH x25519 (eq. 3072 bits RSA) FS

256P

TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) ECDH x25519 (eq. 3072 bits RSA) FS

128

TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (0xc028) ECDH x25519 (eq. 3072 bits RSA) FS

256

TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (0xc027) ECDH x25519 (eq. 3072 bits RSA) FS

128

Thanks and have a nice day,
^JLam

Hello,

I disagree with the recommendation to use port 465 instead of 587.

587 and TLS match.

465 and TLS mismatch.

Moreover on their Microsoft infrastructure (Mail Pro and Exchange) OVH has never supported SMTP on port 465.

Your problem may be quite different.The SSH environment on the high-end hosting solutions is contained in a restricted environment which is not the same as the one in which the webserver runs. This restricted environment has several networking limitations.