Changeset 3262


Ignore:
Timestamp:
Apr 26, 2009, 8:36:17 PM (11 years ago)
Author:
rub
Message:

merge -c3261 from trunk to branch 2.0

Resolved issue 0000977: Error on sendmail with smtp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/class_smtp_mail.inc.php

    r3260 r3262  
    7474  }
    7575
     76  function add_recipients(&$recipients, $headers, $type_header)
     77  {
     78    if (preg_match('/^\s*'.$type_header.'\s*:.*/mi', $headers, $matches) != 0)
     79    {
     80      $list = explode(',', $matches[0]);
     81      foreach ($list as $email)
     82      {
     83        if (strpos($email, '<') !== false)
     84        {
     85           $email = preg_replace('/.*<(.*)>.*/i', '$1', $email);
     86        }
     87        $recipients[] = trim($email);
     88      }
     89    }
     90  }
     91
    7692  // Adaptation of pun_mail
    7793  function mail($to, $subject, $message, $headers = '')
    7894  {
    7995    $this->no_error = true;
    80 
    81     $recipients = explode(',', $to);
    8296
    8397    // Are we using port 25 or a custom port?
     
    119133      $this->server_parse('250');
    120134
    121       if (preg_match('/^\s*to\s*:.*/mi', $headers) === 0)
     135      if ((preg_match('/^\s*to\s*:.*/mi', $headers) === 0) and !empty($to))
    122136      {
    123         $to_header = 'To:'.implode(',', array_map(create_function('$email','return "<".$email.">";'), $recipients));
     137        $to_header = 'To:'.implode(',', array_map(create_function('$email','return "<".$email.">";'), explode(',', $to)));
    124138      }
    125139      else
     
    127141        $to_header = '';
    128142      }
     143
     144      if (!empty($to))
     145      {
     146        $recipients = explode(',', $to);
     147      }
     148      else
     149      {
     150        $recipients = array();
     151      }
     152
     153      $this->add_recipients($recipients, $headers, 'Cc');
     154      $this->add_recipients($recipients, $headers, 'Bcc');
    129155
    130156      @reset($recipients);
Note: See TracChangeset for help on using the changeset viewer.