diff options
author | rub <rub@piwigo.org> | 2009-04-26 18:36:17 +0000 |
---|---|---|
committer | rub <rub@piwigo.org> | 2009-04-26 18:36:17 +0000 |
commit | d50e5963ffe7cbf3ad6d268a812ea94a4b4d0ca4 (patch) | |
tree | 3b3b77ff433a8ae83977724c165a49edd6bf7721 /include/class_smtp_mail.inc.php | |
parent | 6d758aec6b7bdb04766de8414814da55fe3e28e3 (diff) |
merge -c3261 from trunk to branch 2.0
Resolved issue 0000977: Error on sendmail with smtp
git-svn-id: http://piwigo.org/svn/branches/2.0@3262 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/class_smtp_mail.inc.php')
-rw-r--r-- | include/class_smtp_mail.inc.php | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/include/class_smtp_mail.inc.php b/include/class_smtp_mail.inc.php index 9ace931db..b26ef1ed4 100644 --- a/include/class_smtp_mail.inc.php +++ b/include/class_smtp_mail.inc.php @@ -73,13 +73,27 @@ class smtp_mail return $this->no_error; } + function add_recipients(&$recipients, $headers, $type_header) + { + if (preg_match('/^\s*'.$type_header.'\s*:.*/mi', $headers, $matches) != 0) + { + $list = explode(',', $matches[0]); + foreach ($list as $email) + { + if (strpos($email, '<') !== false) + { + $email = preg_replace('/.*<(.*)>.*/i', '$1', $email); + } + $recipients[] = trim($email); + } + } + } + // Adaptation of pun_mail function mail($to, $subject, $message, $headers = '') { $this->no_error = true; - $recipients = explode(',', $to); - // Are we using port 25 or a custom port? if (strpos($this->host, ':') !== false) { @@ -118,15 +132,27 @@ class smtp_mail $this->server_write('MAIL FROM:<'.$this->email_webmaster.'>'."\r\n"); $this->server_parse('250'); - if (preg_match('/^\s*to\s*:.*/mi', $headers) === 0) + if ((preg_match('/^\s*to\s*:.*/mi', $headers) === 0) and !empty($to)) { - $to_header = 'To:'.implode(',', array_map(create_function('$email','return "<".$email.">";'), $recipients)); + $to_header = 'To:'.implode(',', array_map(create_function('$email','return "<".$email.">";'), explode(',', $to))); } else { $to_header = ''; } + if (!empty($to)) + { + $recipients = explode(',', $to); + } + else + { + $recipients = array(); + } + + $this->add_recipients($recipients, $headers, 'Cc'); + $this->add_recipients($recipients, $headers, 'Bcc'); + @reset($recipients); while (list(, $email) = @each($recipients)) { |