php - 如何在 monolog 中使用 swiftmailer 处理程序

标签 php swiftmailer handlers monolog

我想知道如何在 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/

相关文章:

php - 学习 PHP 面向对象的方面

php - 如何使用 DATEDIFF 选择行?

c++ - 方法处理程序的隐式转换?

android - 在android中使用Ksoap2时处理超时

c# - 在 C# 中,如何轻松更改事件处理程序的名称?

php - 分页面板应保持静态

javascript - 范围变量在 REST API POST 请求中丢失值

php - symfony2 无法通过 gmail 发送电子邮件

php - 使用 Gmail 进行 SMTP 时,可以设置不同的 "from"地址吗?

php - Swiftmailer 仅发送来自 BCC 的 999 封电子邮件