php - How to properly Send Email Using Cron job in my Laravel application? ← (PHP, Laravel)
one text
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('asamoa69@yahoo.com')->send(new BirthdaymessageMail());
}
}
Please what's the right way to do this? I need assistance. Thank you.