1. Go to this page and download the library: Download codeldev/laravel-mail-log 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/ */
use CodelDev\LaravelMailLog\Models\LaravelMailLog;
// Get all logged emails
$emails = LaravelMailLog::all();
// Get emails sent to a specific address (not available for SQLite)
$emails = LaravelMailLog::query()
->whereJsonContains('to', '[email protected]')
->latest()
->get();
// Get emails sent today
$emails = LaravelMailLog::query()
->whereDate('created_at', today())
->get();
// Search by subject
$emails = LaravelMailLog::query()
->where('subject', 'like', '%Welcome%')
->latest()
->get();
use CodelDev\LaravelMailLog\Models\LaravelMailLog as BaseMailLog;
class MailLog extends BaseMailLog
{
public function scopeToRecipient($query, string $email)
{
return $query->whereJsonContains('to', $email);
}
}