N
N
Ninazu2016-01-05 09:49:45
Yii
Ninazu, 2016-01-05 09:49:45

How to trigger Error Log in Yii2 Swiftmailer?

$mailer = Yii::$app->mailer;
$mailer->enableSwiftMailerLogging = true;

$mailer->compose()
...
->send();

//Как получить ошибки которые возникли при отправке?

The option /debug/default/view?panel=mail is not very suitable, it is more interesting to get it as a variable

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2016-01-05
@Ninazu

Judging by this commit https://github.com/yiisoft/yii2-swiftmailer/commit... everything is logged into the general log.

+ * In order to catch logs written by this class, you need to setup a log route for 'yii\swiftmailer\Logger::add' category.
 + * For example:
 + *
 + * ~~~
 + * 'log' => [
 + *     'targets' => [
 + *         [
 + *             'class' => 'yii\log\FileTarget',
 + *             'categories' => ['yii\swiftmailer\Logger::add'],
 + *         ],
 + *     ],
 + * ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question