LoginSignup
4

More than 5 years have passed since last update.

EC-CUBE3 でメールの送信ログを出力しよう!

Last updated at Posted at 2015-12-11

EC-CUBE3 でメールが送信できない!
そんな時は、メールの送信ログを出力してみましょう。

swift-mailer-psr-logger-plugin を使います。

設定方法

EC-CUBE3 のルートディレクトリ直下で以下のコマンドを実行します。

php composer.phar require gcrico/swift-mailer-psr-logger-plugin @stable

src/Eccube/Application.php にある initMailer() 関数の最後あたり(EC-CUBE-3.0.7は408行目付近)に、以下のコードを追加します。

src/Eccube/Application.php
        $app = $this;
        $this->extend('mailer', function ($mailer) use ($app) {
            $app_logger = $app['monolog'];
            $mailer_logger = new \gcrico\SwiftMailerPsrLoggerPlugin\SwiftMailerPsrLoggerPlugin($app_logger);
            $mailer->registerPlugin($mailer_logger);
            return $mailer;
        });

こうすることで、メールの送信ログが出力されるようになります。
詳細なログを出力させたい場合は、 app/config/eccube/log.yml を以下のように設定しましょう。

app/config/eccube/log.yml
log:
    prefix: site_
    suffix:
    format: Y-m-d
    action_level: INFO
    log_level: DEBUG
    max_files: 90
    exclude_keys:
        - password
        - app

本当は、このログ出力を EC-CUBE3 本体でサポートしたくて、いろいろ頑張ったのですが、まだ実現に至っていません...

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4