Example #1
0
 /**
  * Method for sending a piece of mail using this transport.
  *
  * @param \r8\Mail $mail The mail to send
  * @return \r8\Mail\Transport Returns a self reference
  */
 public function send(\r8\Mail $mail)
 {
     if (!$mail->fromExists()) {
         throw new \r8\Exception\Variable('From Address', '"From" Address must be set to send an email');
     }
     if (!$mail->hasTos()) {
         throw new \r8\Exception\Variable('To Address', '"To" Address must be set to send an email');
     }
     $this->internalSend($mail);
     return $this;
 }
Example #2
0
 /**
  * Returns an array of headers that will be sent with this message
  *
  * @param \r8\Mail $mail The piece of mail whose headers should be returned
  * @return Array The key is the header name, the value is the value of
  *      the header
  */
 public function getHeaderList(\r8\Mail $mail)
 {
     $result = array();
     if ($mail->fromExists()) {
         $result['From'] = self::formatAddress($mail->getFrom(), $mail->getFromName());
     }
     if ($mail->hasTos()) {
         $result['To'] = $this->getToString($mail);
     }
     if ($mail->hasCCs()) {
         $result['CC'] = $this->getCCString($mail);
     }
     if ($mail->hasBCCs()) {
         $result['BCC'] = $this->getBCCString($mail);
     }
     if ($mail->subjectExists()) {
         $result['Subject'] = $mail->getSubject();
     }
     $result['Date'] = date('r');
     $result["MIME-Version"] = "1.0";
     if ($mail->messageIDExists()) {
         $result['Message-ID'] = '<' . $mail->getMessageID() . '>';
     }
     if ($mail->htmlExists() && $mail->textExists()) {
         $result['Content-Type'] = "multipart/alternative;\nboundary='" . $mail->getBoundary() . "'";
     } else {
         if ($mail->htmlExists()) {
             $result['Content-Type'] = 'text/html; charset="ISO-8859-1"';
             $result["Content-Transfer-Encoding"] = "7bit";
         } else {
             $result['Content-Type'] = 'text/plain; charset="ISO-8859-1"';
             $result["Content-Transfer-Encoding"] = "7bit";
         }
     }
     return $result;
 }