I am working on a Laravel project and try to send emails using mailjet. Sending mails local works fine, but using the same settings on my centos 7 webserver gives me an error which I can't resolve for days now.
.env settings
MAIL_MAILER=smtp
MAIL_DRIVER=smtp
MAIL_HOST=in-v3.mailjet.com
MAIL_PORT=587
MAIL_USERNAME=***
MAIL_PASSWORD=***
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@***.com
MAIL_FROM_NAME="${APP_NAME}"
Sending the email
Mail::send('emails.auth.verify-email', ['token' => $token, 'user' => $user], function($message) use($user){
$message->to($user->email);
$message->subject('Email Verification Mail');
});
Error on CentOS 7 Server
Swift_TransportException
Connection could not be established with host in-v3.mailjet.com :stream_socket_client(): unable to connect to tcp://in-v3.mailjet.com:587 (Permission denied)
I already tried
- restarting apache
sudo reboot
php artisan cache:clear
php artisan config:clear
- I have also tried mailgun instead of mailjet, got me the same error (only on the server, worked fine local)
- hard coding the connection credentials in config/mail.php instead of loading them from the .env file
as requested in the comments, here is the output of: dd(Config::get('mail'))
array:4 [▼
"default" => "smtp"
"mailers" => array:8 [▼
"smtp" => array:8 [▼
"transport" => "smtp"
"host" => "in-v3.mailjet.com"
"port" => 587
"encryption" => "tls"
"username" => "***"
"password" => "***"
"timeout" => null
"auth_mode" => null
]
"ses" => array:1 [▼
"transport" => "ses"
]
"mailgun" => array:1 [▼
"transport" => "mailgun"
]
"postmark" => array:1 [▼
"transport" => "postmark"
]
"sendmail" => array:2 [▼
"transport" => "sendmail"
"path" => "/usr/sbin/sendmail -t -i"
]
"log" => array:2 [▼
"transport" => "log"
"channel" => null
]
"array" => array:1 [▼
"transport" => "array"
]
"failover" => array:2 [▼
"transport" => "failover"
"mailers" => array:2 [▼
0 => "smtp"
1 => "log"
]
]
]
"from" => array:2 [▼
"address" => "[email protected]"
"name" => "PokeShares"
]
"markdown" => array:2 [▼
"theme" => "default"
"paths" => array:1 [▼
0 => "/var/www/pokeshares/resources/views/vendor/mail"
]
]
]
These look like the correct settings.
Any help is appreciated!
My Answer:
you please provide more context or clarify your question?
Rate this post
5 of 5 based on 1298 votesComments