Example #1
0
 /**
  * @dataProvider providerConstruct
  */
 public function testConstruct($string, $name, $email, $toString)
 {
     $address = new Address($string);
     $this->assertEquals($name, $address->getDisplayName());
     $this->assertEquals($email, $address->getEmailAddress());
     $this->assertEquals($toString, $address->__toString());
 }
 /**
  * Parses the addresses of the provided message and adds them to the headers of the message
  * @param zibo\library\mail\Message $message The message to parse the addresses of
  * @return null
  */
 private function parseAddresses(Message $message)
 {
     $from = $message->getFrom();
     $to = $message->getTo();
     $cc = $message->getCc();
     $bcc = $message->getBcc();
     $replyTo = $message->getReplyTo();
     if (empty($to) && empty($cc) && empty($bcc)) {
         throw new MailException('No recipients set');
     }
     if (!$from) {
         $sender = Zibo::getInstance()->getConfigValue(self::CONFIG_SENDER);
         if ($sender) {
             $from = new Address($sender);
         }
     }
     if ($from) {
         $this->headers[self::HEADER_FROM] = self::HEADER_FROM . ': ' . $from->__toString();
     }
     $debug = Zibo::getInstance()->getConfigValue(self::CONFIG_DEBUG);
     if ($debug) {
         $debugAddress = new Address($debug);
         $this->addAddressesToHeaders(self::HEADER_TO, array($debugAddress));
     } else {
         $this->addAddressesToHeaders(self::HEADER_TO, $to);
         $this->addAddressesToHeaders(self::HEADER_CC, $cc);
         $this->addAddressesToHeaders(self::HEADER_BCC, $bcc);
         if ($replyTo) {
             $this->headers[self::HEADER_REPLY_TO] = self::HEADER_REPLY_TO . ': ' . $replyTo->__toString();
         }
     }
 }