1) { $cci = array_unique(array_merge($cci, $pour)); $pour = [lire_config('facteur/adresse_envoi_email',lire_config('email_webmaster'))]; } // docs attachés function entier($val) { return is_integer($val); } $Tid_doc = array_filter(explode(',', $id_docs), 'entier'); //$Tpdfs_ok = _request('Tpdfs_ok'); $pieces_jointes = []; /* if ($f = charger_fonction('traiter_av_pdf', 'gamumail', true)) { $options = $f($options, $auteur, $Tclient, $Tpdf); } if ($f = charger_fonction($slug . '_traiter_av_pdf', 'gamumail', true)) { $options = $f($options, $auteur, $Tclient, $Tpdf); } */ // les documents joints if (!empty($Tid_doc)) { foreach ($Tid_doc as $id_document) { $Tdocument = sql_fetsel('titre,fichier,extension','spip_documents','id_document='.intval($id_document)); $destination = _DIR_IMG.$Tdocument['fichier']; $extension = $Tdocument['extension']; if ($Tdocument['titre']) { $nom_fichier = $Tdocument['titre'] .".".$extension; } else { $nom_fichier = basename($Tdocument['fichier']); } $type_mime = bigup_get_mime_type_extension($extension); $pieces_jointes[] = [ 'chemin' => $destination, 'nom' => $nom_fichier, 'encodage' => 'base64', 'mime' => $type_mime ]; } } /* // les pdfs $Tpdf_dell = []; if (!empty($Tpdfs_ok) and is_array($Tpdfs_ok)) { if (array_key_exists('fichier', $Tpdf)) { $Tpdf = [$Tpdf]; } $recup_pdf = charger_fonction('charger_pdf','inc'); foreach ($Tpdfs_ok as $pdf) { foreach ($Tpdf as $p) { if ($p['fichier'] === $pdf) { $c = $p['contexte']; $nom = $p['nom']; } } $pdf = $recup_pdf($pdf, $c); $nom_fichier = $nom.'.pdf'; $destination = _DIR_TMP.basename($nom_fichier); $Tpdf_dell[] = $destination; file_put_contents($destination,$pdf); $pieces_jointes[] = [ 'chemin' => $destination, 'nom' => $nom_fichier, 'encodage' => 'base64', 'mime' => 'application/pdf' ]; } } */ $html_header = ''; if (find_in_path('gamumail/'.$slug .'_html_header.html')) { $html_header = recuperer_fond('gamumail/'.$slug . '_html_header', $options); } elseif(find_in_path('gamumail/html_header.html')) { $html_header = recuperer_fond('gamumail/html_header', $options); } $html_footer = ''; if (find_in_path('gamumail/'.$slug . '_html_footer.html')) { $html_footer = recuperer_fond('gamumail/'.$slug . '_html_footer', $options); } elseif (find_in_path('gamumail/html_footer.html')) { $html_footer = recuperer_fond('gamumail/html_footer', $options); } $html = $html_header . $html . $html_footer; $corps = [ 'html' => $html, 'texte' => $texte, 'cc' => $cc, 'cci' => $cci, 'pieces_jointes' => $pieces_jointes ]; if ($f = charger_fonction('traiter', 'gamumail', true)) { $corps = $f($corps, $options, $slug, $auteur, $Tclient, $Tpdf, $redirect); } if ($f = charger_fonction($slug . '_traiter', 'gamumail', true)) { $corps = $f($corps, $options, $slug, $auteur, $Tclient, $Tpdf, $redirect); } $envoyer_mail = charger_fonction('envoyer_mail', 'inc/'); $ok = $envoyer_mail($pour, $sujet, $corps); if (!$ok) { spip_log("Erreur d'envoi du mail : ","gamumail"); spip_log($corps,"roc"); $retour['message_erreur'] = _T("gamumail:erreur_envoi_mail"); } else { $retour['message_ok'] = _T('gamumail:mail_envoye'); } /* // on supprime les pdfs temporaires if (count($Tpdf_dell)) { foreach ($Tpdf_dell as $pdf) { unlink($pdf); } } if ($redirect) { $retour['redirect'] = $redirect; } */ return $retour; }