I'm trying to send emails through Laravel and Gmail usage, nevertheless, it throws this error:
Connection could not be established with host "mailpit:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo for mailpit failed: No such host is known.
I don't understand why it tries to connect to Mailpit instead of Gmail.
My .env file looks like this:
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=est.juan.arango1@unimilitar.edu.co
MAIL_PASSWORD=[google app password]
MAIL_ENCRYPTION=ssl
and my routing looks like this:
Route::get('/senMail', function () {
try {
Mail::to('est.juan.arango1@unimilitar.edu.co’')->send(new Subscribe());
} catch (Throwable $e) {
return '<div>FAILED ' . $e . '</div>';
}
});
the subscribe template is a regular php artisan make:mail Subscribe --markdown=emails.subscribers
I tried to run php artisan cache:clear
and php artisan config:clear
but error kept being thrown, I also changed port 587 to 465 with no success.
Also tried this config in config/mail.php
file:
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
by @aynber: "Try grep -R mailpit * | egrep -v storage from your project root to find out where it's been referenced."
Its been a little long time since i had thsi issue, but this helped me find the line of code that was still using other smtp provider. Just replaced it with mine.