govindalohani's avatar

Symfony\Component\Mailer\Exception\TransportException

I tried to upgrade to laravel 9 from laravel 8

Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

My tried solution:

'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            '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'),
            'auth_mode' => null, <-- Defining the SMTP auth_mode in the mail configuration file is no longer required as per upgrade guide. tried adding and removing both
            'verify_peer' => false, <-- This is added
        ],
}

I am using docker image for mailtrap and running project in docker. my .env for localhost

MAIL_DRIVER=smtp
MAIL_HOST=host.docker.internal
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME=Example

I even tried adding MAIL_EHLO_DOMAIN=host.docker.internal but did not work.

php artisan config:clear
php artisan config:cache

and restarted horizon

It was working in version 8. Please help me. Thanks in advance

0 likes
4 replies
maggiemartin88's avatar

Did you ever solve this? I am getting an authentication error. Before we also had auth_mode as null.

govindalohani's avatar
'default' => env('MAIL_MAILER',  'smtp')

'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            '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'),
            'verify_peer' => false,
        ]


#Env file for mailtrap
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=username
MAIL_PASSWORD=pass

Make sure verify_peer is false and as per laravel documentation, we don't need auth_mode in version 9. Replace env username and password with your username and password.

pagac's avatar

How do I configure Mailtrap in Laravel 9, and what specific settings need to be updated in the config/mail.php file to successfully send emails using Mailtrap's SMTP server?

Please or to participate in this conversation.