【问题标题】:how to use swiftmailer handler with monolog如何将 swiftmailer 处理程序与独白一起使用
【发布时间】:2014-07-23 14:57:29
【问题描述】:

我想知道如何在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
我应该做任何其他步骤/配置吗?

对不起,如果我的问题非常基本。
谢谢。

【问题讨论】:

    标签: php swiftmailer handlers monolog


    【解决方案1】:

    您需要查看 Swift_Mailer 文档以了解如何设置邮件程序。

    https://swiftmailer.symfony.com/docs/sending.html

    一旦你设置了你的邮件程序,你应该将它传递给 $mailer 变量的新 SwiftMailerHandler()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-16
      • 1970-01-01
      相关资源
      最近更新 更多