alecpl
2010-04-23 bf67d60e435a6f01b835a0d5afb9737f81560433
program/include/rcube_smtp.php
@@ -82,6 +82,12 @@
    if (isset($smtp_host_url['host']) && isset($smtp_host_url['scheme']))
      $smtp_host = sprintf('%s://%s', $smtp_host_url['scheme'], $smtp_host_url['host']);
    // remove TLS prefix and set flag for use in Net_SMTP::auth()
    if (preg_match('#^tls://#i', $smtp_host)) {
      $smtp_host = preg_replace('#^tls://#i', '', $smtp_host);
      $use_tls = true;
    }
    if (!empty($CONFIG['smtp_helo_host']))
      $helo_host = $CONFIG['smtp_helo_host'];
    else if (!empty($_SERVER['SERVER_NAME']))
@@ -107,11 +113,12 @@
    $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']);
    $smtp_pass = str_replace('%p', $RCMAIL->decrypt($_SESSION['password']), $CONFIG['smtp_pass']);
    $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type'];
    // attempt to authenticate to the SMTP server
    if ($smtp_user && $smtp_pass)
    {
      $result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type);
      $result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type, $use_tls);
      if (PEAR::isError($result))
      {
        $this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $this->conn->_code));
@@ -226,7 +233,13 @@
    // Send the message's headers and the body as SMTP data.
    if (PEAR::isError($result = $this->conn->data($data, $text_headers)))
    {
      $this->error = array('label' => 'smtperror', 'vars' => array('msg' => $result->getMessage()));
      $err = $this->conn->getResponse();
      if (count($err)>1 && $err[0] != 354 && $err[0] != 250)
        $msg = sprintf('[%d] %s', $err[0], $err[1]);
      else
        $msg = $result->getMessage();
      $this->error = array('label' => 'smtperror', 'vars' => array('msg' => $msg));
      $this->response[] .= "Failed to send data";
      $this->reset();
      return false;
@@ -379,14 +392,14 @@
    
    $addresses = array();
    $recipients = rcube_explode_quoted_string(',', $recipients);
    reset($recipients);
    while (list($k, $recipient) = each($recipients))
    {
      $a = explode(" ", $recipient);
      while (list($k2, $word) = each($a))
      {
        if ((strpos($word, "@") > 0) && (strpos($word, "\"")===false))
        if (strpos($word, "@") > 0 && $word[strlen($word)-1] != '"')
        {
          $word = preg_replace('/^<|>$/', '', trim($word));
          if (in_array($word, $addresses)===false)
@@ -398,5 +411,3 @@
  }
}
?>