Esempio n. 1
0
 /**
  * Sends a redirect (a/k/a resent) message.
  *
  * @param Horde_Stream $message  Message content.
  *
  * @throws Horde_Spam_Exception
  */
 protected function _redirectMessage(Horde_Stream $message)
 {
     /* Split up headers and message. */
     $message->rewind();
     $eol = $message->getEOL();
     $headers = $message->getToChar($eol . $eol);
     if (!strlen($headers)) {
         throw new Horde_Spam_Exception('Invalid message reported, header not found');
     }
     $body = fopen('php://temp', 'r+');
     stream_copy_to_stream($message->stream, $body, -1, $message->pos());
     /* We need to set the Return-Path header to the sending user - see RFC
      * 2821 [4.4]. */
     $headers = preg_replace('/return-path:.*?(\\r?\\n)/i', 'Return-Path: <' . $this->_from_addr . '>$1', $headers);
     try {
         $this->_mail->send($this->_email, array('_raw' => $headers, 'from' => $this->_from_addr), $body);
     } catch (Horde_Mail_Exception $e) {
         $this->_logger->warn($e);
         throw new Horde_Spam_Exception($e);
     }
 }
Esempio n. 2
0
 /**
  * Sends this message.
  *
  * @param string $email                 The address list to send to.
  * @param Horde_Mime_Headers $headers   The Horde_Mime_Headers object
  *                                      holding this message's headers.
  * @param Horde_Mail_Transport $mailer  A Horde_Mail_Transport object.
  * @param array $opts                   Additional options:
  * <pre>
  *   - broken_rfc2231: (boolean) Attempt to work around non-RFC
  *                     2231-compliant MUAs by generating both a RFC
  *                     2047-like parameter name and also the correct RFC
  *                     2231 parameter (@since 2.5.0).
  *                     DEFAULT: false
  *   - encode: (integer) The encoding to use. A mask of self::ENCODE_*
  *             values.
  *             DEFAULT: Auto-determined based on transport driver.
  * </pre>
  *
  * @throws Horde_Mime_Exception
  * @throws InvalidArgumentException
  */
 public function send($email, $headers, Horde_Mail_Transport $mailer, array $opts = array())
 {
     $old_status = $this->_status;
     $this->isBasePart(true);
     /* Does the SMTP backend support 8BITMIME (RFC 1652)? */
     $canonical = true;
     $encode = self::ENCODE_7BIT;
     if (isset($opts['encode'])) {
         /* Always allow 7bit encoding. */
         $encode |= $opts['encode'];
     } elseif ($mailer instanceof Horde_Mail_Transport_Smtp) {
         try {
             $smtp_ext = $mailer->getSMTPObject()->getServiceExtensions();
             if (isset($smtp_ext['8BITMIME'])) {
                 $encode |= self::ENCODE_8BIT;
             }
         } catch (Horde_Mail_Exception $e) {
         }
         $canonical = false;
     } elseif ($mailer instanceof Horde_Mail_Transport_Smtphorde) {
         try {
             if ($mailer->getSMTPObject()->data_8bit) {
                 $encode |= self::ENCODE_8BIT;
             }
         } catch (Horde_Mail_Exception $e) {
         }
         $canonical = false;
     }
     $msg = $this->toString(array('canonical' => $canonical, 'encode' => $encode, 'headers' => false, 'stream' => true));
     /* Add MIME Headers if they don't already exist. */
     if (!isset($headers['MIME-Version'])) {
         $headers = $this->addMimeHeaders(array('encode' => $encode, 'headers' => $headers));
     }
     if (!empty($this->_temp['toString'])) {
         $headers->addHeader('Content-Transfer-Encoding', $this->_temp['toString']);
         switch ($this->_temp['toString']) {
             case '8bit':
                 if ($mailer instanceof Horde_Mail_Transport_Smtp) {
                     $mailer->addServiceExtensionParameter('BODY', '8BITMIME');
                 }
                 break;
         }
     }
     $this->_status = $old_status;
     $rfc822 = new Horde_Mail_Rfc822();
     try {
         $mailer->send($rfc822->parseAddressList($email)->writeAddress(array('encode' => $this->getHeaderCharset() ?: true, 'idn' => true)), $headers->toArray(array('broken_rfc2231' => !empty($opts['broken_rfc2231']), 'canonical' => $canonical, 'charset' => $this->getHeaderCharset())), $msg);
     } catch (InvalidArgumentException $e) {
         // Try to rebuild the part in case it was due to
         // an invalid line length in a rfc822/message attachment.
         if ($this->_failed) {
             throw $e;
         }
         $this->_failed = true;
         $this->_sanityCheckRfc822Attachments();
         try {
             $this->send($email, $headers, $mailer, $opts);
         } catch (Horde_Mail_Exception $e) {
             throw new Horde_Mime_Exception($e);
         }
     } catch (Horde_Mail_Exception $e) {
         throw new Horde_Mime_Exception($e);
     }
 }
Esempio n. 3
0
 /**
  * Sends this message.
  *
  * @param string $email                 The address list to send to.
  * @param Horde_Mime_Headers $headers   The Horde_Mime_Headers object
  *                                      holding this message's headers.
  * @param Horde_Mail_Transport $mailer  A Horde_Mail_Transport object.
  * @param array $opts                   Additional options:
  *   - encode: (integer) The encoding to use. A mask of self::ENCODE_*
  *             values.
  *             DEFAULT: Auto-determined based on transport driver.
  *
  * @throws Horde_Mime_Exception
  * @throws InvalidArgumentException
  */
 public function send($email, $headers, Horde_Mail_Transport $mailer, array $opts = array())
 {
     $old_basepart = $this->_basepart;
     $this->_basepart = true;
     /* Does the SMTP backend support 8BITMIME (RFC 1652)? */
     $canonical = true;
     $encode = self::ENCODE_7BIT;
     if (isset($opts['encode'])) {
         /* Always allow 7bit encoding. */
         $encode |= $opts['encode'];
     } elseif ($mailer instanceof Horde_Mail_Transport_Smtp) {
         try {
             $smtp_ext = $mailer->getSMTPObject()->getServiceExtensions();
             if (isset($smtp_ext['8BITMIME'])) {
                 $encode |= self::ENCODE_8BIT;
             }
         } catch (Horde_Mail_Exception $e) {
         }
         $canonical = false;
     } elseif ($mailer instanceof Horde_Mail_Transport_Smtphorde) {
         try {
             if ($mailer->getSMTPObject()->data_8bit) {
                 $encode |= self::ENCODE_8BIT;
             }
         } catch (Horde_Mail_Exception $e) {
         }
         $canonical = false;
     }
     $msg = $this->toString(array('canonical' => $canonical, 'encode' => $encode, 'headers' => false, 'stream' => true));
     /* Add MIME Headers if they don't already exist. */
     if (!$headers->getValue('MIME-Version')) {
         $headers = $this->addMimeHeaders(array('encode' => $encode, 'headers' => $headers));
     }
     if (!empty($this->_temp['toString'])) {
         $headers->replaceHeader('Content-Transfer-Encoding', $this->_temp['toString']);
         switch ($this->_temp['toString']) {
             case '8bit':
                 if ($mailer instanceof Horde_Mail_Transport_Smtp) {
                     $mailer->addServiceExtensionParameter('BODY', '8BITMIME');
                 } elseif ($mailer instanceof Horde_Mail_Transport_Smtphorde) {
                     $mailer->send8bit = true;
                 }
                 break;
         }
     }
     $this->_basepart = $old_basepart;
     $rfc822 = new Horde_Mail_Rfc822();
     try {
         $mailer->send($rfc822->parseAddressList($email)->writeAddress(array('encode' => $this->getHeaderCharset(), 'idn' => true)), $headers->toArray(array('canonical' => $canonical, 'charset' => $this->getHeaderCharset())), $msg);
     } catch (Horde_Mail_Exception $e) {
         throw new Horde_Mime_Exception($e);
     }
 }
Esempio n. 4
0
 /**
  * Sends this message.
  *
  * @param string $email                 The address list to send to.
  * @param Horde_Mime_Headers $headers   The Horde_Mime_Headers object
  *                                      holding this message's headers.
  * @param Horde_Mail_Transport $mailer  A Horde_Mail_Transport object.
  * @param array $opts                   Additional options:
  *   - encode: (integer) The encoding to use. A mask of self::ENCODE_*
  *             values.
  *             DEFAULT: Auto-determined based on transport driver.
  *
  * @throws Horde_Mime_Exception
  * @throws InvalidArgumentException
  */
 public function send($email, $headers, Horde_Mail_Transport $mailer, array $opts = array())
 {
     $old_basepart = $this->_basepart;
     $this->_basepart = true;
     /* Does the SMTP backend support 8BITMIME (RFC 1652) or
      * BINARYMIME (RFC 3030) extensions? Requires Net_SMTP version
      * 1.3+. */
     $encode = self::ENCODE_7BIT;
     if (isset($opts['encode'])) {
         /* Always allow 7bit encoding. */
         $encode |= $opts['encode'];
     } else {
         if ($mailer instanceof Horde_Mail_Transport_Smtp) {
             try {
                 $smtp_ext = $mailer->getSMTPObject()->getServiceExtensions();
                 if (isset($smtp_ext['8BITMIME'])) {
                     $encode |= self::ENCODE_8BIT;
                 }
                 if (isset($smtp_ext['BINARYMIME'])) {
                     $encode |= self::ENCODE_BINARY;
                 }
             } catch (Horde_Mail_Exception $e) {
             }
         }
     }
     $msg = $this->toString(array('canonical' => true, 'encode' => $encode, 'headers' => false, 'stream' => true));
     /* Make sure the message has a trailing newline. */
     fseek($msg, -1, SEEK_END);
     switch (fgetc($msg)) {
         case "\r":
             if (fgetc($msg) != "\n") {
                 fputs($msg, "\n");
             }
             break;
         default:
             fputs($msg, "\r\n");
             break;
     }
     rewind($msg);
     /* Add MIME Headers if they don't already exist. */
     if (!$headers->getValue('MIME-Version')) {
         $headers = $this->addMimeHeaders(array('encode' => $encode, 'headers' => $headers));
     }
     if (!empty($this->_temp['toString'])) {
         $headers->replaceHeader('Content-Transfer-Encoding', $this->_temp['toString']);
         switch ($this->_temp['toString']) {
             case 'binary':
                 $mailer->addServiceExtensionParameter('BODY', 'BINARYMIME');
                 break;
             case '8bit':
                 $mailer->addServiceExtensionParameter('BODY', '8BITMIME');
                 break;
         }
     }
     $this->_basepart = $old_basepart;
     $rfc822 = new Horde_Mail_Rfc822();
     try {
         $mailer->send($rfc822->parseAddressList($email)->writeAddress(array('encode' => $this->getHeaderCharset(), 'idn' => true)), $headers->toArray(array('canonical' => true, 'charset' => $this->getHeaderCharset())), $msg);
     } catch (Horde_Mail_Exception $e) {
         throw new Horde_Mime_Exception($e);
     }
 }
Esempio n. 5
0
 /**
  */
 public function __get($name)
 {
     switch ($name) {
         case 'eai':
             $this->getSMTPObject();
             return $this->_smtp->data_intl;
     }
     return parent::__get($name);
 }