我想知道如何在 Monolog
packagist 中使用 SwiftMailerHandler
?
在 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
设置邮件程序后,您应该将其传递给 $mailer 变量的新 SwiftMailerHandler()。
关于php - 如何在 monolog 中使用 swiftmailer 处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24012361/