Reputation: 3444
I am using Laravel 8 + queues + Mailgun API to send emails from my local machine.
I can't send emails. I have this error :
[2020-12-19 11:50:26] local.ERROR: Connection could not be established with host smtp.mailgun.org :stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:ssl3_get_record:wrong version number {"exception":"[object] (Swift_TransportException(code: 0): Connection could not be established with host smtp.mailgun.org :stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:ssl3_get_record:wrong version number at C:\\Users\\Dominique\\Documents\\Workspace\\market-gardener\\market-gardener-back\\vendor\\swiftmailer\\swiftmailer\\lib\\classes\\Swift\\Transport\\StreamBuffer.php:269)
[stacktrace]
I think I have a configuration issues somewhere. I tried a lot of things without success. My conf :
.env :
MAIL_PORT=2525
MAILGUN_ENDPOINT=api.mailgun.net
MAILGUN_DOMAIN=sandbox___xxxxx_____________.mailgun.org
MAILGUN_SECRET=secret___xxxxxxxxxxxxxxxxx______
MAIL_ENCRYPTION=ssl
config/email :
'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,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
Is this kind of conf correct? Where are my errors? Of course I already tried to clear the cache and config.
Upvotes: 2
Views: 1831
Reputation: 2329
You have to make sure you provide all the values of the environment variable if not it won't work. in my own case, I added this line in my env file
MAILGUN_SECRET=6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd
Upvotes: 0
Reputation: 3444
A parameter was missing in the.env (see the doc here)
I only added MAIL_MAILER=mailgun in the .env , and it works fine now.
My .env is now :
MAIL_MAILER=mailgun
MAIL_PORT=2525
MAILGUN_ENDPOINT=api.mailgun.net
MAILGUN_DOMAIN=sandbox___xxxxx_____________.mailgun.org
MAILGUN_SECRET=secret___xxxxxxxxxxxxxxxxx______
MAIL_ENCRYPTION=ssl
Upvotes: 0
Reputation: 7571
Here's a working version of the Mailgun setup I use:
MAIL_HOST=smtp.eu.mailgun.org
MAIL_PORT=587
[email protected]
MAIL_FROM_NAME=example
[email protected]
MAIL_PASSWORD="123abc456def"
MAIL_ENCRYPTION=tls
The keys are coupled to the default config/mail.php
file as seen here:
https://github.com/laravel/laravel/blob/8.x/config/mail.php
Note the usage of tls
and port number 587
. The MAIL_HOST
may also differ. Mailgun should probably have a page on their website where this configuration is outlined.
Upvotes: 1