I trying to send email in laravel using localhost but not receiving email in inbox neither in spam while it successfully send from laravel application not showing any error. This is my controller funciton.
$user = $request->all();
Mail::send('emails.email', ['testVar' => $user], function ($m) use ($user) {
$m->from('raja.waleed21@gmail.com', $user['doctor_firstname']);
$m->to('raja.waleed21@gmail.com', $user['doctor_firstname']);
});
This is my email template.
<html>
<head></head>
<body>
{{ $testVar['doctor_firstname'] }}
</body>
</html>
this is .env file setting.
MAIL_MAILER=mailgun
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=raja.waleed2121@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
This is my config/mail.php
file
<?php
return [
'default' => env('MAIL_MAILER', 'smtp'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
what is the issue as I have not receiving email nor any error.Thanks in advance.