/** * 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); }
/** * 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'); }