Source of file SMTP_LogEmailWriter.php
Size: 1,072 Bytes - Last Modified: 2022-02-21T10:01:24+00:00
/var/www/docs.ssmods.com/process/src/code/SMTP_LogEmailWriter.php
123456789101112131415161718192021222324252627282930313233343536 | <?php /** * Thanks to Dean Rather <dean@deanrather.com> * https://github.com/deanrather */ class SMTP_LogEmailWriter extends SS_LogEmailWriter { /** * Send an email to the email address set in * this writer. */ public function _write($event) { // If no formatter set up, use the default if(!$this->_formatter) { $formatter = new SS_LogErrorEmailFormatter(); $this->setFormatter($formatter); } $formattedData = $this->_formatter->format($event); $subject = $formattedData['subject']; $data = $formattedData['data']; if(!isset($GLOBALS['LogMailSend'])){ $email = new Email(); $email->setTo($this->emailAddress); $email->setSubject($subject); $email->setBody($data); $email->setFrom(Config::inst()->get('SS_LogEmailWriter', 'log_email')); Config::inst()->update('SmtpMailer', 'credentials', 'log'); // choose "log" credentials set $email->send(); $GLOBALS['LogMailSend'] = true; // prevent resending logmail, if smtp is the source for the error } } } ?> |