示例#1
0
文件: Mailer.php 项目: tillk/vufind
 /**
  * Send a text message to the specified provider.
  *
  * @param string $provider The provider ID to send to
  * @param string $to       The phone number at the provider
  * @param string $from     The email address to use as sender
  * @param string $message  The message to send
  *
  * @throws \VuFind\Exception\Mail
  * @return void
  */
 public function text($provider, $to, $from, $message)
 {
     $knownCarriers = array_keys($this->carriers);
     if (empty($provider) || !in_array($provider, $knownCarriers)) {
         throw new MailException('Unknown Carrier');
     }
     $to = $this->filterPhoneNumber($to) . '@' . $this->carriers[$provider]['domain'];
     $from = empty($from) ? $this->defaultFrom : $from;
     $subject = '';
     return $this->mailer->send($to, $from, $subject, $message);
 }
示例#2
0
 /**
  * Test transport exception.
  *
  * @return void
  *
  * @expectedException        VuFind\Exception\Mail
  * @expectedExceptionMessage Boom
  */
 public function testTransportException()
 {
     $transport = $this->getMock('Zend\\Mail\\Transport\\TransportInterface');
     $transport->expects($this->once())->method('send')->will($this->throwException(new \Exception('Boom')));
     $mailer = new Mailer($transport);
     $mailer->send('*****@*****.**', '*****@*****.**', 'subject', 'body');
 }