コード例 #1
0
 /**
  * @return array|bool
  * @throws MailWrapperSendException
  * @throws MailWrapperSetupException
  */
 public static function send()
 {
     $args = func_get_args();
     $message = array_shift($args);
     // re-add message to args as PHPMailer is both transport and message
     if ($message instanceof \PHPMailer) {
         $args[] = $message;
     }
     $message = MessageTransformer::convert($message);
     if (!count($args)) {
         throw new MailWrapperSetupException('No Transports available');
     }
     foreach ($args as $transport) {
         if (!$transport) {
             throw new MailWrapperSetupException('NULL Transport');
         }
         try {
             return static::sendVia($transport, $message);
         } catch (\Exception $e) {
             if ($e instanceof MailWrapperSetupException) {
                 throw $e;
             }
             if (self::$debug) {
                 throw $e;
             }
             continue;
         }
     }
     throw new MailWrapperSendException('No Transports succeeded');
 }
コード例 #2
0
 /**
  *
  */
 public function testConvert()
 {
     $transport = MailgunManager::newInstance('TEST', 'example.com');
     $message = TesterMessageMailgun::getValid();
     $newMessage = MessageTransformer::convert($message, 'mailgun', $transport);
     $this->assertInstanceOf('BespokeSupport\\MailWrapper\\MailgunMessage', $newMessage);
 }
コード例 #3
0
 /**
  * @param null $message
  * @return MailWrappedMessage
  * @throws MailWrapperSetupException
  */
 public static function newInstance($message = null)
 {
     switch (true) {
         case $message instanceof Swift_Message:
         case $message instanceof PHPMailer:
         case $message instanceof MessageBuilder:
         case $message instanceof Message:
         case $message instanceof MailWrappedMessage:
             $message = MessageTransformer::getWrappedMessage($message);
             break;
         case $message:
             throw new MailWrapperSetupException('Unknown Message');
         default:
             break;
     }
     return new self($message);
 }
コード例 #4
0
 /**
  *
  */
 public function testTransformToWrappedMessage()
 {
     $message = new MailWrappedMessage();
     $newMessage = MessageTransformer::getWrappedMessage($message);
     $this->assertInstanceOf('BespokeSupport\\MailWrapper\\MailWrappedMessage', $newMessage);
 }
コード例 #5
0
 /**
  *
  */
 public function testConvert()
 {
     $message = TesterMessageZend::getValid();
     $newMessage = MessageTransformer::convert($message, 'zend');
     $this->assertInstanceOf('Zend\\Mail\\Message', $newMessage);
 }
コード例 #6
0
 /**
  *
  */
 public function testConvert()
 {
     $message = TesterMessagePhpMailer::getValid();
     $newMessage = MessageTransformer::convert($message, 'phpmailer');
     $this->assertInstanceOf('PHPMailer', $newMessage);
 }
コード例 #7
0
 /**
  *
  */
 public function testConvert()
 {
     $message = TesterMessageSwift::getValid();
     $newMessage = MessageTransformer::convert($message, 'swift');
     $this->assertInstanceOf('\\Swift_Message', $newMessage);
 }