You can do this with scheduling. I use beanstalk and it works great (I'm also doing it for reminder emails).
Make a new command (php artisan make:command SendReminderEmails)
Edit the new file app/Console/Commands/SendReminderEmails.php
public function fire()
{
// Get the users where they haven't activated or w/e
$pending_users = User::has('emails', '=', 1)
->pending()
->where('created_at', '<=', Carbon::now()->subDays(3))
->get();
// dd($pending_users);
foreach ($pending_users as $user) {
$data = [
'name' => $user->name,
'email' => $user->email,
'subject' => 'Subject Here - Reminder',
'user_id' => $user->id,
'token' => $activate_token, // if you need a token or link, just add it and use in the email view
];
Queue::push(new SendReminderEmails($data));
}
}
Make a new Job (php artisan make:job SendReminderEmail)
protected $data;
public function __construct($data)
{
$this->data = $data;
}
public function handle()
{
$data = $this->data;
Mail::send('emails.reminder_html', $data, function($message) use ($data)
{
$message->to($data['email'], $data['name']);
$message->subject($data['subject']);
});
}
You will need to add these to app/Console/Kernel.php
protected $commands = [
'App\Console\Commands\SendReminderEmails',
];
protected function schedule(Schedule $schedule)
{
$schedule->command('company:reminder-emails')->everyMinute();
}
End notes
Probably got some class names not linked up right (plural/singular) but you get the idea :) If you need to do Bcc, do that instead. I do a check for how many emails users get, that's easy enough to change. Depends on how you want to do it.