PHP code example of buildcode / laravel-database-emails
1. Go to this page and download the library: Download buildcode/laravel-database-emails library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
buildcode / laravel-database-emails example snippets
protected function schedule(Schedule $schedule)
{
$schedule->command('email:send')->everyMinute()->withoutOverlapping(5);
}
Email::compose()->queue();
// On a specific connection
Email::compose()->queue(connection: 'sqs');
// On a specific queue
Email::compose()->queue(queue: 'email-queue');
// Delay (send mail in 10 minutes)
Email::compose()->queue(delay: now()->addMinutes(10));
namespace App\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
use Stackkit\LaravelDatabaseEmails\SendEmailJob;
class CustomSendEmailJob extends SendEmailJob implements ShouldQueue
{
// Define custom retries, backoff, etc...
}
use Stackkit\LaravelDatabaseEmails\Email;
$schedule->command('model:prune', [
'--model' => [Email::class],
])->daily();
use Stackkit\LaravelDatabaseEmails\Email;
public function register(): void
{
Email::pruneWhen(function (Email $email) {
return $email->where(...);
});
}