php - How to properly Send Email Using Cron job in my Laravel application?
Get the solution ↓↓↓I have a markdown Birthday Notification email Template. I want to send a notification to user on their birthday using Cron job. The Cron job works perfectly but isn't working when I try to send email or add Email function to handle it.
This is my Code please
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Mail\BirthdaymessageMail;
use Illuminate\Support\Facades\Mail;
use App\Models\Employee;
class BirthdayCron extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'birthday:cron';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Notify Employee On Birthday';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->birthDayNotification();
}
private function birthDayNotification()
{
Mail::to('[email protected]')->send(new BirthdaymessageMail());
}
}
Please what's the right way to do this? I need assistance. Thank you.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.