pwg_mail($mailto,$args) ; $mailto=$infos->mailto; $subject=$infos->subject; $content=$infos->content; $headers=$infos->headers; $result=$infos->result; $args=$infos->args; $nb_destinataires=$infos->nb_destinataires; $ret =clj_send_mail($result, $mailto, $subject, $content, $headers, $args,$nb_destinataires); return $ret; //================================ // Photographie //================================ $ret="false"; $message =""; ob_start(); $ret = mail($mailto, $subject,$content, $headers); $message = ob_get_contents(); ob_end_clean(); Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); return $ret; return true ; //=========================== //return false; // envoie //return true ; // pas d'envoie //=========================== } /************************************ * *************************************/ static public function send_mail_to( $to){ return $to; } /************************************ * *************************************/ static public function send_mail_subject($cvt_subject){ return $cvt_subject; } /************************************ * *************************************/ static public function send_mail_content($content){ return $content; } /************************************ * *************************************/ static public function send_mail_headers($headers_init){ return $headers_init; } /* * sends an email, using Piwigo specific informations * * @param: * - to: receiver(s) of the mail (list separated by comma). * - args: function params of mail function: * o from: sender [default value webmaster email] * o Cc: array of carbon copy receivers of the mail. [default value empty] * o Bcc: array of blind carbon copy receivers of the mail. [default value empty] * o subject [default value 'Piwigo'] * o content: content of mail [default value ''] * o content_format: format of mail content [default value 'text/plain'] * o email_format: global mail format [default value $conf_mail['default_email_format']] * o theme: template to use [default get_default_theme()] * * @return boolean (Ok or not) * pour mise au point . * http://www.faqs.org/rfcs/rfc2822.html */ function pwg_mail($to, $args = array()){ global $conf, $conf_mail, $lang_info, $page; global $mails_options ; remove_event_handler('send_mail', 'pwg_send_mail'); if (empty($to) and empty($args['Cc']) and empty($args['Bcc'])) { $retour->mailto= ""; $retour->subject= ""; $retour->content= ""; $retour->headers= ""; $retour->args= $args ; $retour->nb_destinataires=0 ; $retour->$result=true ; return $retour ; } if (!isset($conf_mail)) { $conf_mail = get_mail_configuration(); } $args['email_format']="text/html"; if (empty($args['email_format'])) { $args['email_format'] = $conf_mail['default_email_format']; } // Compute root_path in order have complete path set_make_full_url(); if (empty($args['from'])) { $args['from'] = $conf_mail['formated_email_webmaster']; } else { $args['from'] = format_email('', $args['from']); } if (empty($args['subject'])) { $args['subject'] = 'Piwigo'; } // Spring cleaning $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject'])); // Ascii convertion $cvt_subject = encode_mime_header($cvt_subject); if (!isset($args['content'])) { $args['content'] = ''; } if (empty($args['content_format'])) { $args['content_format'] = 'text/plain'; } if ($conf_mail['send_bcc_mail_webmaster'] || $mails_options['check_send_webmaster']=="on") { $args['Bcc'][] = $conf_mail['formated_email_webmaster']; } $webmaster = $conf_mail['formated_email_webmaster']; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $Cc="";$Bcc=""; if (empty($mailto)) $mailto=""; $nb_destinataires=0; if( isset($args['Bcc'])){ $nb_destinataires=count($args['Bcc']); $Bcc= implode(',', $args['Bcc']) ; } if( isset($args['Cc'])){ $nb_destinataires +=count($args['Cc']); $Cc= implode(',', $args['Cc']) ; } if(!empty($to)) $nb_destinataires +=count(explode(",",$to)); if($nb_destinataires==1 && empty($to)){ if (isset($args['Bcc']) && count($args['Bcc'])==1) $to = array_pop($args['Bcc']); if (isset($args['Cc']) && count($args['Cc'])==1){ $to = array_pop($args['Cc']); } } $mailto=$to ; //============================================= // Test Si Mailto vide //============================================= if ($mails_options['check_mailto'] == 'on' && empty($mailto) ) { //=== suppression webmaster adresse dans les copies . $match_email = $webmaster; $new_args=array(); if( isset($args['Bcc'])) foreach($args['Bcc'] as $key => $val){ if (!preg_match('/'. $conf_mail['email_webmaster'] .'/', $val)){ array_push($new_args, $val); } } $args['Bcc']=$new_args; //======================================================================= $new_args=array(); if( isset($args['Cc'])) foreach($args['Cc'] as $key => $val){ if (!preg_match('/'. $conf_mail['email_webmaster'] .'/', $val)){ array_push($new_args, $val); } } $args['Cc']=$new_args; $nb_destinataires =count($args['Bcc'])+count($args['Cc']) ; //======================================================================= $mailto = $webmaster; $nb_destinataires++; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if (empty($args['theme'])) { $args['theme'] = get_default_theme(); } //============================================ // TEST EOL // //=========================================== // Note: // Si le message n'est pas reçu, essayez d'utiliser uniquement un caractère LF (\n). // Quelques agents de transfert de mail Unix de mauvaise qualité remplacent le caractère LF // par le caractère CRLF automatiquement //(ce qui revient à doubler le caractère CR si le caractère CRLF est utilisé). // Ceci doit être un dernier recours car cela ne correspond pas à la » RFC 2822. //====================================================== // drop LF barre //====================================================== $Eol="\n"; $pattern="/free.fr|club/"; if( preg_match($pattern, $mailto) || preg_match($pattern, $Cc) || preg_match($pattern, $Bcc)){ $Eol="\r\n"; } //==================================================== // Headers //==================================================== $headers = 'From: '.$args['from'].$Eol; $headers.= 'Reply-To: '.$args['from'].$Eol; //============================================================================= // Note: // L'implémentation de la fonction mail() sous Windows diffère de manière significative avec l'implémentation // Unix. // Tout d'abord, il n'utilise pas un programme local pour composer les messages, // mais opère uniquement et directement sur les sockets, // ce qui signifie qu'un MTA est nécessairement à l'écoute sur un socket du réseau // (qui peut être soit sur le réseau local ou sur une machine distante). // // Deuxièmement, les en-têtes personnalisés comme From:, Cc:, Bcc: et Date: ne sont pas interprétés // par le MTA dans un premier temps, mais sont analysés par PHP. // // De plus, le paramètre to ne doit pas être une adresse sous la forme // "Quelque chose ". // La commande mail n'analysera pas correctement ceci lors de la discussion avec le MTA. //============================================================================= $Cc="";$Bcc=""; if (!empty($args['Cc'])) { $Cc=implode(",",$args['Cc']); if ($mails_options['check_header_carbon'] == 'on') $Cc= get_strict_email_list( $Cc); $headers.= 'Cc: '.$Cc.$Eol; $args['Cc']=explode(", ",$Cc); } if (!empty($args['Bcc'])) { $Bcc=implode(",",$args['Bcc']); if ($mails_options['check_header_carbon'] == 'on') $Bcc= get_strict_email_list( $Bcc); $headers.= 'Bcc: '.$Bcc.$Eol; $args['Bcc']=explode(", ",$Bcc); } if (!empty($mailto)) { if ($mails_options['check_header_carbon'] == 'on') $mailto= get_strict_email_list($mailto); } //===================================== // List on content-type test si doublé //===================================== $content_type_list[] = $args['email_format']; if (!empty($conf_mail['alternative_email_format']) && $conf_mail['alternative_email_format']!= $args['email_format'] ) { $content_type_list[] = $conf_mail['alternative_email_format']; $headers.= 'Content-Type: multipart/alternative;'.$Eol; }else{ // $headers.= 'Content-Type: '.$args['email_format'].';'.$Eol; $headers .= 'Content-type: '.$args['email_format'].'; charset='.get_pwg_charset(). ' ' .$Eol; } //===================================== $headers.= ' boundary="---='.$conf_mail['boundary_key'].'";'.$Eol; $headers.= ' reply-type=original'.$Eol; $headers.= 'MIME-Version: 1.0'.$Eol; $headers.= 'X-Mailer: Piwigo Mailer'.$Eol; //===================================== $content = ''; foreach (array_unique($content_type_list) as $content_type) { // key compose of indexes witch allow ti cache mail data $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['theme']; if (!isset($conf_mail[$cache_key])) { $conf_mail[$cache_key]['theme'] = get_mail_template($content_type, $args['theme']); $conf_mail[$cache_key]['theme']->set_filename('mail_header', 'header.tpl'); $conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl'); $conf_mail[$cache_key]['theme']->assign( array( //Header 'BOUNDARY_KEY' => $conf_mail['boundary_key'], 'CONTENT_TYPE' => $content_type, 'CONTENT_ENCODING' => get_pwg_charset(), // Footer 'GALLERY_URL' => get_gallery_home_url(), 'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => PHPWG_URL, 'TITLE_MAIL' => urlencode(l10n('A comment on your site')), 'MAIL' => get_webmaster_mail_address() )); if ($content_type == 'text/html') { if ($conf_mail[$cache_key]['theme']->smarty->template_exists('global-mail-css.tpl')) { $conf_mail[$cache_key]['theme']->set_filename('css', 'global-mail-css.tpl'); $conf_mail[$cache_key]['theme']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css'); } $file = PHPWG_ROOT_PATH.'themes/'.$args['theme'].'/mail-css.tpl'; if (is_file($file)) { $conf_mail[$cache_key]['theme']->set_filename('css', realpath($file)); $conf_mail[$cache_key]['theme']->assign_var_from_handle('MAIL_CSS', 'css'); } } // what are displayed on the header of each mail ? $conf_mail[$cache_key]['header'] = $conf_mail[$cache_key]['theme']->parse('mail_header', true); // what are displayed on the footer of each mail ? $conf_mail[$cache_key]['footer'] = $conf_mail[$cache_key]['theme']->parse('mail_footer', true); } // Header if(count($content_type_list)>1) $content.= $conf_mail[$cache_key]['header']; // Content if (($args['content_format'] == 'text/plain') and ($content_type == 'text/html')) { $content.= '

'. nl2br( preg_replace("/(http:\/\/)([^\s,]*)/i", "$1$2", htmlspecialchars($args['content']))). '

'; } else if (($args['content_format'] == 'text/html') and ($content_type == 'text/plain')) { // convert html text to plain text $content.= strip_tags($args['content']); } else { $content.= $args['content']; } // Footer $content.= $conf_mail[$cache_key]['footer']; // Close boundary if(count($content_type_list)>1) $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'.$Eol; }// fin each //================================================================== //~ // Close boundary //~ $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; //=========================================== // Note: //Si le message n'est pas reçu, essayez d'utiliser uniquement un caractère LF (\n). // Quelques agents de transfert de mail Unix de mauvaise qualité remplacent le caractère LF // par le caractère CRLF automatiquement //(ce qui revient à doubler le caractère CR si le caractère CRLF est utilisé). // Ceci doit être un dernier recours car cela ne correspond pas à la » RFC 2822. //====================================================== // drop LF barre //====================================================== // $pattern ="/" . preg_quote($pattern, '/')."/" ; $pattern="/free.fr|club/"; if( preg_match($pattern, $mailto) || preg_match($pattern, $headers) ){ $content= preg_replace('#(?mailto= $mailto; $retour->subject= $cvt_subject; $retour->content= $content; $retour->headers= $headers; $retour->args= $args ; $retour->nb_destinataires=$nb_destinataires ; $retour->result=false ; return $retour ; } } ?>