burnthebook/craft-log-mail-adapter

Log mail transport adapter for Craft CMS

Maintainers

Package info

github.com/Burnthebook/craft-log-mail-adapter

Issues

Documentation

Type:craft-plugin

pkg:composer/burnthebook/craft-log-mail-adapter

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 1

0.0.2 2026-03-11 15:05 UTC

This package is auto-updated.

Last update: 2026-03-13 10:35:09 UTC


README

This plugin adds a mail transport adapter that logs emails to a file instead of sending them. It is recommended for local development only.

Requirements

  • Craft CMS 5.0.0+
  • PHP 8.2+

Installation

# Go to your Craft project
cd /path/to/project

# Install the plugin
composer require burnthebook/craft-log-mail-adapter

# Enable the plugin
php craft plugin/install log-mail-adapter

Setup

Open Settings → Email and set Transport Type to "Log Adapter". Set the log file path to where you want emails written (default: @storage/logs/mail.log).

Each email is logged as a JSON line entry.

config/app.php snippet

<?php

use Craft;
use craft\helpers\MailerHelper;
use burnthebook\logmail\LogAdapter;

return [
    '*' => [
        'components' => [
            // Live mailer settings if overriden
            // ...
        ]
    ],
    'dev' => [
        'components' => [
            'mailer' => function() {
                // Get the stored email settings
                $settings = craft\helpers\App::mailSettings();

                // Override the transport adapter to Log
                $settings->transportType = \burnthebook\logmail\LogAdapter::class;
                // use default settings from plugin (storage/logs/mail.log)
                $settings->transportSettings = [];

                $config = craft\helpers\App::mailerConfig($settings);
                return Craft::createObject($config);
            }
        ]
    ],
];