承接 empinet/laravel-outbound-mail-log 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

empinet/laravel-outbound-mail-log

最新稳定版本:v1.0.4

Composer 安装命令:

composer require empinet/laravel-outbound-mail-log

包简介

Log outbound emails sent by Laravel into a database table.

README 文档

README

Tests Quality Latest Version on Packagist Total Downloads

Log outbound emails sent by Laravel into a database table.

This package listens to Laravel's mail sending events and stores outgoing email metadata (subject, recipients, sender, body, headers, attachments, mailable/notification class, mailer, and send status) so you can inspect what was sent.

What gets logged

  • subject
  • from / to / cc / bcc
  • HTML or text body (configurable)
  • headers (configurable)
  • attachment filenames
  • mailable or notification class (when available)
  • mailer name
  • status (sending then sent)
  • sent timestamp

Installation

Install the package with Composer:

composer require empinet/laravel-outbound-mail-log

Publish and run the migration:

php artisan vendor:publish --tag="outbound-mail-log-migrations"
php artisan migrate

You can also use the default Laravel migration publish tag:

php artisan vendor:publish --tag="migrations"
php artisan migrate

Publish the config file:

php artisan vendor:publish --tag="outbound-mail-log-config"

You can also use the default Laravel config publish tag:

php artisan vendor:publish --tag="config"

Configuration

The package ships disabled by default.

Set this in your .env:

OUTBOUND_MAIL_LOG_ENABLED=true

Available config options (config/outbound-mail-log.php):

return [
    'enabled' => env('OUTBOUND_MAIL_LOG_ENABLED', false),
    'cleanup_records_after' => env('OUTBOUND_MAIL_LOG_CLEANUP_RECORDS_AFTER', false),
    'log_headers' => env('OUTBOUND_MAIL_LOG_LOG_HEADERS', true),
    'log_body' => env('OUTBOUND_MAIL_LOG_LOG_BODY', true),
    'exclude_classes' => [],
];

Excluding specific mailables or notifications

Use exclude_classes to skip logging for specific classes.

'exclude_classes' => [
    App\Mail\PasswordResetMail::class,
    App\Notifications\SensitiveNotification::class,
],

Class matching is exact (fully qualified class name).

Laravel 10 limitation: some legacy build() mailables do not expose mailable class metadata during MessageSending, so class-based exclusion may not apply for those emails.

Recommended .env values for local/testing:

OUTBOUND_MAIL_LOG_ENABLED=true
OUTBOUND_MAIL_LOG_LOG_BODY=true
OUTBOUND_MAIL_LOG_LOG_HEADERS=true
OUTBOUND_MAIL_LOG_CLEANUP_RECORDS_AFTER=false

For production, consider setting OUTBOUND_MAIL_LOG_LOG_BODY=false if emails may contain sensitive content.

Usage

After installing, publishing migrations, and enabling the package, send mail normally using Laravel mailables/notifications.

use Illuminate\Support\Facades\Mail;

Mail::raw('Hello from the app', function ($message): void {
    $message->to('user@example.com')
        ->from('noreply@example.com')
        ->subject('Test message');
});

Then inspect logs from your app:

use Empinet\OutboundMailLog\Models\OutboundMailLog;

$latest = OutboundMailLog::query()
    ->latest('id')
    ->first();

Cleanup command

To remove old records based on OUTBOUND_MAIL_LOG_CLEANUP_RECORDS_AFTER, run:

php artisan outbound-mail-log:cleanup

Set OUTBOUND_MAIL_LOG_CLEANUP_RECORDS_AFTER=false to disable cleanup.

To schedule cleanup daily, add this in your routes/console.php:

use Illuminate\Support\Facades\Schedule;

Schedule::command('outbound-mail-log:cleanup')->daily();

Notes

  • A log entry is created when sending starts (sending) and marked as sent after Laravel dispatches MessageSent.
  • The package supports Mailables, Notification mail channel messages, and closure/raw emails.

Testing

composer test

Releasing

  • Releases are tag-based.
  • Every push to master triggers the release workflow and creates the next patch tag automatically.
  • If no tag exists yet, the workflow bootstraps the first release at v1.0.0.
  • You can also run the release workflow manually and pass an explicit version like 1.2.0.
  • Packagist updates are handled via Packagist auto-update integration.

If Composer shows could not detect the root package version in local development, that is normal before your first release tag. It does not affect package behavior.

Changelog

Please see CHANGELOG for recent changes.

License

The MIT License (MIT). See LICENSE.

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固