Source of file PostmarkSwiftMailer.php
Size: 0,983 Bytes - Last Modified: 2019-11-18T10:14:48+00:00
/var/www/docs.ssmods.com/process/src/src/Control/Email/PostmarkSwiftMailer.php
123456789101112131415161718192021222324252627282930313233343536 | <?php namespace DNADesign\AlertManager; use Exception; use SilverStripe\Control\Email\SwiftMailer; use SilverStripe\Core\Convert; /** * Wraps the standard SilverStripe SwiftMailer * so that we can handle HTTP responses from the API properly */ class PostmarkSwiftMailer extends SwiftMailer { /** * @param Email $message * @return bool Whether the sending was "successful" or not */ public function send($message) { $swiftMessage = $message->getSwiftMessage(); $failedRecipients = array(); $result = $this->sendSwift($swiftMessage, $failedRecipients); $message->setFailedRecipients($failedRecipients); if ($result->getStatusCode() == 200) { return true; } else { $body = Convert::json2array($result->getBody()); throw new Exception($result->getStatusCode() . ': ' . $result->getReasonPhrase() . ': ' . $body['Message']); return false; } } } |