Changeset 25361
- Timestamp:
- Nov 6, 2013, 8:12:18 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_mail.inc.php
r25360 r25361 114 114 if (is_array($input)) 115 115 { 116 if (!isset($input['name'])) 117 { 118 $input['name'] = ''; 119 } 116 120 return $input; 117 121 } … … 132 136 } 133 137 } 138 139 /** 140 * Return a clean array of hashmaps (email, name) from various inputs 141 * - comma separated list 142 * - array of emails 143 * - single hashmap (email[, name]) 144 * @since 2.6 145 * 146 * @param mixed $data 147 * @return string[][] 148 */ 149 function get_clean_recipients_list($data) 150 { 151 if (empty($data)) 152 { 153 return array(); 154 } 155 else if (is_array($data)) 156 { 157 $values = array_values($data); 158 if (!is_array($values[0])) 159 { 160 $keys = array_keys($data); 161 if (is_int($keys[0])) 162 { // simple array of emails 163 foreach ($data as &$item) 164 { 165 $item = array( 166 'email' => $item, 167 'name' => '', 168 ); 169 } 170 unset($item); 171 } 172 else 173 { // hashmap of one recipient 174 $data = array(unformat_email($data)); 175 } 176 } 177 else 178 { // array of hashmaps 179 $data = array_map('unformat_email', $data); 180 } 181 } 182 else 183 { 184 $data = explode(',', $data); 185 $data = array_map('unformat_email', $data); 186 } 134 187 188 return $data; 189 } 135 190 136 191 /** … … 155 210 return implode(',', array_unique($result)); 156 211 } 157 158 212 159 213 /** … … 494 548 $mail = new PHPMailer; 495 549 496 $recipients = !is_array($to) ? explode(',', $to) : $to; 497 foreach ($recipients as $recipient) 498 { 499 $recipient = unformat_email($recipient); 550 foreach (get_clean_recipients_list($to) as $recipient) 551 { 500 552 $mail->addAddress($recipient['email'], $recipient['name']); 501 553 } … … 532 584 if (!empty($args['Cc'])) 533 585 { 534 foreach ($args['Cc'] as $cc) 535 { 536 $cc = unformat_email($cc); 537 $mail->addCC($cc['email'], $cc['name']); 586 foreach (get_clean_recipients_list($args['Cc']) as $recipient) 587 { 588 $mail->addCC($recipient['email'], $recipient['name']); 538 589 } 539 590 } 540 591 541 592 // Bcc 593 $Bcc = get_clean_recipients_list(@$args['Bcc']); 542 594 if ($conf_mail['send_bcc_mail_webmaster']) 543 595 { 544 $args['Bcc'][] = get_webmaster_mail_address(); 545 } 546 if (!empty($args['Bcc'])) 547 { 548 foreach ($args['Bcc'] as $bcc) 549 { 550 $bcc = unformat_email($bcc); 551 $mail->addBCC($bcc['email'], $bcc['name']); 596 $Bcc[] = get_webmaster_mail_address(); 597 } 598 if (!empty($Bcc)) 599 { 600 foreach ($Bcc as $recipient) 601 { 602 $mail->addBCC($recipient['email'], $recipient['name']); 552 603 } 553 604 }
Note: See TracChangeset
for help on using the changeset viewer.