Question

i would like to know how exactly to use SwiftMailerHandler within Monolog packagist?
In the Monolog documentation i don't see any usage example regarding SwiftMailerHandler or maybe i missed out.
Here is the SwiftMailerHandler constructor code:

/**
 * @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;
}  

But i still don't know how to set the \Swift_Mailer $mailer mentioned above.
Is there any other steps / configuration i should do?

Sorry if my question is very basic.
Thanks.

Was it helpful?

Solution

You will need to look at the Swift_Mailer docs as to how to set up the mailer.

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

Once you have your mailer set up that is what you should pass into the new SwiftMailerHandler() for the $mailer variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top