ARTICLE AD BOX
I am using Laravel 10 (Symfony Mailer) to send emails via the HIN.CH SMTP server. However, I am consistently getting a TransportException regarding an SSL certificate hostname mismatch.
The Error:
Symfony\Component\Mailer\Exception\TransportException: Unable to connect with STARTTLS: stream_socket_enable_crypto(): Peer certificate CN='223.164.139.118.host.secureserver.net' did not match expected CN='smtp.mail.hin.ch'
It seems the mail server is presenting a generic GoDaddy/Secureserver certificate instead of one for smtp.mail.hin.ch.
My Configuration in config/mail.php: I have already tried to bypass the peer verification using the stream options, but the error persists:
'smtp' => [ 'transport' => 'smtp', 'host' => env('MAIL_HOST'), 'port' => env('MAIL_PORT', 587), 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'timeout' => null, 'local_domain' => env('MAIL_EHLO_DOMAIN'), 'stream' => [ 'ssl' => [ 'allow_self_signed' => true, 'verify_peer' => false, 'verify_peer_name' => false, ], ], ],What I have tried:
Ran php artisan config:clear and php artisan cache:clear multiple times.
Manually deleted bootstrap/cache/config.php.
Tried using a direct MAILER_DSN in .env: smtp://user:[email protected]:587?verify_peer=0.
Changed the MAIL_HOST to 223.164.139.118.host.secureserver.net in .env. This resolves the SSL error but leads to 535 Incorrect authentication data, likely because HIN.ch requires the correct domain for authentication.
Tried Port 465 with ssl encryption.
Environment:
PHP Version: 8.x (Specify your version here, e.g., 8.2)
Laravel Version: 10.x (Specify your version here)
Hosting: Shared Hosting / VPS (Specify your hosting type)
Question: Why is Symfony Mailer ignoring the stream configuration in mail.php? Is there a way to force-bypass the hostname mismatch for this specific SMTP provider without getting an authentication error?
