как использовать обработчик Swiftmailer с монологом
-
21-12-2019 - |
Вопрос
я хотел бы знать, как именно использовать SwiftMailerHandler
в пределах Monolog
упаковщик?
в Monolog
документации, я не вижу ни одного примера использования относительно SwiftMailerHandler
или может я пропустил.
Здесь SwiftMailerHandler
код конструктора:
/**
* @param \Swift_Mailer $mailer The mailer to use
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
* @param integer $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
{
parent::__construct($level, $bubble);
$this->mailer = $mailer;
if (!$message instanceof \Swift_Message && is_callable($message)) {
$message = call_user_func($message);
}
if (!$message instanceof \Swift_Message) {
throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
}
$this->message = $message;
}
Но я до сих пор не знаю, как установить \Swift_Mailer $mailer
упомянутое выше.
Есть ли какие-либо другие шаги/конфигурация, которые мне следует сделать?
Извините, если мой вопрос очень простой.
Спасибо.
Решение
Вам нужно будет просмотреть документацию Swift_Mailer, чтобы узнать, как настроить почтовую программу.
https://swiftmailer.symfony.com/docs/sending.html
Как только вы настроите почтовую программу, вам следует передать ее в новый SwiftMailerHandler() для переменной $mailer.