I'm trying to send an email using laravel.
I tried something like:
api.php:
Route::get('emailAnimalEncontrado', function () {
$data = array(
'name' => 'Novo animal encontrado em Franca. Você pode ajudá-lo?'
);
Mail::send('email', $data, function ($message){
$message->from('[email protected]', 'Novo animal encontrado em francaa.');
$message->to('[email protected]')->subject('teste email laravel');
});
return response()->json('Email enviado com sucesso', 201);
});
My .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=SENHAEMAIL
MAIL_ENCRYPTION=null
In resources / views / email.blade.php:
<html lang="pt-br">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
</head>
<body>
OI MUNDO
</body>
</html>
In mail.php:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Renato Veronese'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('[email protected]'),
'password' => env('SENHAEMAIL'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],