PHP code example of timedoor / mail-logger

1. Go to this page and download the library: Download timedoor/mail-logger 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/ */

    

timedoor / mail-logger example snippets


    'providers' => [
        //
        \Timedoor\MailLogger\MailLoggerServiceProvider::class
    ]

$schedule->command('mail-logger:resend-unsent-mail')->daily();

$schedule->command('mail-logger:prune --hours=72')->daily();



use Timedoor\MailLogger\Logger\MailLogger;
use Timedoor\MailLogger\Models\MailLog;

class MailController extends Controller
{
    public function resend(MailLog $email)
    {
        MailLogger::resendMailById($email->id, true); //true for --now option

        return redirect()->back();
    }
    
    public function resendAll(MailLog $email)
    {
        MailLogger::resendUnsentMails(true); //true for --now option

        return redirect()->back();
    }
    
    public function prune($x)
    {
        MailLogger::pruneMails(now()->subHours($x)); // prune emails older than $x hours

        return redirect()->back();
    }
}
bash
php artisan vendor:publish --tag=mail-logger

php artisan migrate
bash
php artisan mail-logger:resend-mail 1
bash
php artisan mail-logger:resend-mail 1 --now
bash
php artisan mail-logger:resend-unsent-mail
bash
php artisan mail-logger:resend-unsent-mail --now