1<?php 2 3/** 4 * PHP sendmail mailing handler 5 * 6 * @author Stephen Billard (sbillard) 7 * @package plugins 8 * @subpackage zenphoto-sendmail 9 */ 10$plugin_is_filter = 5 | CLASS_PLUGIN; 11$plugin_description = gettext("Zenphoto outgoing mail handler based on the PHP <em>mail</em> facility."); 12$plugin_author = "Stephen Billard (sbillard)"; 13$plugin_disable = (zp_has_filter('sendmail') && !extensionEnabled('zenphoto_sendmail')) ? sprintf(gettext('Only one Email handler plugin may be enabled. <a href="#%1$s"><code>%1$s</code></a> is already enabled.'), stripSuffix(get_filterScript('sendmail'))) : ''; 14$plugin_category = gettext('Mail'); 15if ($plugin_disable) { 16 enableExtension('zenphoto_sendmail', 0); 17} else { 18 zp_register_filter('sendmail', 'zenphoto_sendmail'); 19} 20 21function zenphoto_sendmail($msg, $email_list, $subject, $message, $from_mail, $from_name, $cc_addresses, $replyTo) { 22 $headers = sprintf('From: %1$s <%2$s>', $from_name, $from_mail) . "\n"; 23 if (count($cc_addresses) > 0) { 24 $cclist = ''; 25 foreach ($cc_addresses as $cc_name => $cc_mail) { 26 $cclist .= ',' . $cc_mail; 27 } 28 $headers .= 'Cc: ' . substr($cclist, 1) . "\n"; 29 } 30 if ($replyTo) { 31 $headers .= 'Reply-To: ' . array_shift($replyTo) . "\n"; 32 } 33 $result = true; 34 foreach ($email_list as $to_mail) { 35 $result = $result && utf8::send_mail($to_mail, $subject, $message, $headers); 36 } 37 if (!$result) { 38 if (!empty($msg)) 39 $msg .= '<br />'; 40 $msg .= sprintf(gettext('<code>zenphoto_sendmail</code> failed to send <em>%s</em> to one or more recipients.'), $subject); 41 } 42 return $msg; 43} 44 45?>