/** * @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'); }
/** * */ public function testConvert() { $transport = MailgunManager::newInstance('TEST', 'example.com'); $message = TesterMessageMailgun::getValid(); $newMessage = MessageTransformer::convert($message, 'mailgun', $transport); $this->assertInstanceOf('BespokeSupport\\MailWrapper\\MailgunMessage', $newMessage); }
/** * @expectedException \BespokeSupport\MailWrapper\MailWrapperSetupException */ public function testConvertNullNull() { MessageTransformer::convert(null, null); }
/** * */ public function testConvert() { $message = TesterMessageZend::getValid(); $newMessage = MessageTransformer::convert($message, 'zend'); $this->assertInstanceOf('Zend\\Mail\\Message', $newMessage); }
/** * */ public function testConvert() { $message = TesterMessagePhpMailer::getValid(); $newMessage = MessageTransformer::convert($message, 'phpmailer'); $this->assertInstanceOf('PHPMailer', $newMessage); }
/** * */ public function testConvert() { $message = TesterMessageSwift::getValid(); $newMessage = MessageTransformer::convert($message, 'swift'); $this->assertInstanceOf('\\Swift_Message', $newMessage); }