Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PeterAyoub's avatar

SSL error on sending mail via laravel smtp

i have an error while sending mails via laravel smtp mail & laravel ignores MAIL_ENCRYPTION value even i have checked .env values

MAIL_ENCRYPTION=tls
MAIL_ENCRYPTION=null
MAIL_ENCRYPTION=""
MAIL_ENCRYPTION=
MAIL_ENCRYPTION=ssl
MAIL_ENCRYPTION=none
... and more

and tried every mail.php values

'encryption' => env('MAIL_ENCRYPTION'),
'encryption' => env('MAIL_ENCRYPTION','tls'),
'encryption' => "",
'encryption' => "null",
'encryption' => null,
... and more

i have tried using

'stream' => [
       'ssl' => [
              'allow_self_signed' => true,
              'verify_peer' => false,
              'verify_peer_name' => false,
       ],
]
or
'verify_peer' => false,
              																			

when iam using 465 ports this error appears whatever MAIL_ENCRYPTION value

Connection could not be established with host "ssl://my-domain-here.com:465": stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:ssl3_get_record:wrong version number

and when iam using 25,587 values this error appears whatever MAIL_ENCRYPTION value

Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error

i have tried smtp online tools like https://dnschecker.org/smtp-test-tool.php , it works with (No Secure Connection and 25,465 ports)

and tried PHPMailer ONLY when using ```$mail->SMTPAutoTLS = false;$mail->SMTPSecure = false;``` , iam using aaPanel , is there any hit to FORCE DISABLE ANY SSL or encryption
0 likes
8 replies
Jsanwo64's avatar

What mail service are you trying to use?

chubbspet's avatar

Seems like the SSL on your local server is not set up correctly. Have you tried non ssl ports and are the ports set up correctly? Is it a linux server?

Jsanwo64's avatar

Try the following

MAIL_MAILER=smtp
MAIL_HOST=yourwebsite.com
MAIL_PORT=465
MAIL_USERNAME= the username  ([email protected])
MAIL_PASSWORD= your password goes here 
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS= [email protected]
MAIL_FROM_NAME="${APP_NAME}"

I out your details leave mail port, encryption and mail from and the mailer the way it is.

Jsanwo64's avatar

Also verify your website ssl certificate is active. That could also Tigger an error.

Jsanwo64's avatar

If you get the error replace the line

MAIL_ENCRYPTION=ssl

With

MAIL_ENCRYPTION=tls
Jsanwo64's avatar

You can install ssl certificate by doing the following

From settings, disable SSL on panel first. You can logout and login using non SSL connection. And go to settings again, enable SSL, select Letsencrypt.
saedyousef's avatar

If you're testing locally, use log as mail driver.

MAIL_DRIVER=log

Please or to participate in this conversation.