Come usare il gestore SwiftMailer con Monolog
-
21-12-2019 - |
Domanda
Vorrei sapere come usare esattamente SwiftMailerHandler
all'interno di Monolog
Packagist?
Nella documentazione Monolog
non vedo alcun esempio di utilizzo per quanto riguarda SwiftMailerHandler
o forse mi sono perso.
Ecco il codice del costruttore 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;
}
.
Ma ancora non so come impostare il \Swift_Mailer $mailer
sopra menzionato.
C'è qualche altro passo / configurazione che dovrei fare?
Scusa se la mia domanda è molto semplice.
Grazie.
Soluzione
dovrai guardare i documenti SWIFT_MAILER su come impostare il mailer.
https://swiftmailer.symfony.com/docs/sending.html
Una volta impostato il tuo set di mailer è ciò che è necessario passare nel nuovo SwiftMailerHandler () per la variabile $ Mailer.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow