Rev 372 | Blame | Last modification | View Log | RSS feed
<?php/*vim: set expandtab tabstop=4 shiftwidth=4: */// +------------------------------------------------------------------------------------------------------+// | PHP version 4.1 |// +------------------------------------------------------------------------------------------------------+// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |// +------------------------------------------------------------------------------------------------------+// | This library is free software; you can redistribute it and/or |// | modify it under the terms of the GNU Lesser General Public |// | License as published by the Free Software Foundation; either |// | version 2.1 of the License, or (at your option) any later version. |// | |// | This library is distributed in the hope that it will be useful, |// | but WITHOUT ANY WARRANTY; without even the implied warranty of |// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |// | Lesser General Public License for more details. |// | |// | You should have received a copy of the GNU Lesser General Public |// | License along with this library; if not, write to the Free Software |// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |// +------------------------------------------------------------------------------------------------------+// CVS : $Id: envoi_mail.php,v 1.4 2005/02/18 13:35:02 david Exp $/*** Titre** Description**@package site_actu_tela//Auteur original :*@author Alexandre GRANIER <alexandre@tela-botanica.org>//Autres auteurs :*@author David Delon <david.delon@clapas.net>*@copyright Tela-Botanica 2000-2004*@version $Revision: 1.4 $ $Date: 2005/02/18 13:35:02 $// +------------------------------------------------------------------------------------------------------+*/// +------------------------------------------------------------------------------------------------------+// | ENTETE du PROGRAMME |// +------------------------------------------------------------------------------------------------------+include_once dirname(realpath(__FILE__)).'/../papyrus/configuration/pap_config_avancee.inc.php' ;include_once dirname(realpath(__FILE__)).'/../papyrus/configuration/pap_config.inc.php' ;include_once 'Mail.php';include_once 'Mail/mime.php';// +------------------------------------------------------------------------------------------------------+// | CORPS du PROGRAMME |// +------------------------------------------------------------------------------------------------------+//Test pour vérifier que la lettre ne sera pas vide//Connexion a la base d'actu// TODO : pas de données de configuration embarquées dans les programmes !!!!mysql_connect(PAP_BDD_SERVEUR, PAP_BDD_UTILISATEUR, PAP_BDD_MOT_DE_PASSE, true) or die('Impossible de se connecter à la base de données : '.mysql_error());mysql_select_db('tela_prod_spip_actu');//Recherche d'articles de moins de 7 jours$requete = "select * from `spip_articles` WHERE `date` >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)" ;$resultat = mysql_query ($requete) or die ("Echec") ;//Si c'est vide on interrompt le scriptif (mysql_num_rows ($resultat) == 0) {exit;}//Récupération de la date du jour pour l'ajouter dans le sujet du mail$traduction_mois[1] = 'Janvier';$traduction_mois[2] = 'Fevrier';$traduction_mois[3] = 'Mars';$traduction_mois[4] = 'Avril';$traduction_mois[5] = 'Mai';$traduction_mois[6] = 'Juin';$traduction_mois[7] = 'Juillet';$traduction_mois[8] = 'Aout';$traduction_mois[9] = 'Septembre';$traduction_mois[10] = 'Octobre';$traduction_mois[11] = 'Novembre';$traduction_mois[12] = 'Decembre';$date_jour = date('j');$date_mois = date('m');$date_annee = date('Y');//Pour traduire en français le nom de mois anglais obtenu par la fonction datefunction traduction ($table,$mois){foreach ($table as $clef => $valeur) {if ($clef == $mois) {$resultat = $valeur;}}return($resultat);}$mois_francais = traduction ($traduction_mois,$date_mois);//Préparation de la chaine de caractères a intégrer dans le sujet$date_lettre = 'du '.$date_jour.' '.$mois_francais.' '.$date_annee;// +------------------------------------------------------------------------------------------------------+$lettre_info_html = file_get_contents("http://www.tela-botanica.org/actu/lettre_info.php");$lettre_info_txt = html_entity_decode(file_get_contents("http://www.tela-botanica.org/actu/lettre_info_txt.php"),ENT_QUOTES,"ISO-8859-15") ;$crlf="\n";$headers ['From'] = 'Association Tela Botanica <accueil@tela-botanica.org>' ;$headers ['Subject'] = 'Lettre d\'information de Tela Botanica '.$date_lettre ;$headers ['Reply-To'] = 'accueil@tela-botanica.org' ;$mime = new Mail_mime($crlf);$mime->setTXTBody($lettre_info_txt);$mime->setHTMLBody($lettre_info_html);$body = $mime->get();$headers = $mime->headers($headers);$mail = & Mail::factory ('mail') ;$mail -> send ('actu@tela-botanica.org', $headers, $body) ;if (PEAR::isError ($mail)) {echo 'erreur d\'envoi' ;}// +------------------------------------------------------------------------------------------------------+// | LISTE de FONCTIONS |// +------------------------------------------------------------------------------------------------------+/*Mettre ici la liste de fonctions.*/// +------------------------------------------------------------------------------------------------------+// | PIED du PROGRAMME |// +------------------------------------------------------------------------------------------------------+/*Partie non obligatoire*//* +--Fin du code ----------------------------------------------------------------------------------------+** $Log: envoi_mail.php,v $* Revision 1.4 2005/02/18 13:35:02 david* Lettre actu format text + html*** +-- Fin du code ----------------------------------------------------------------------------------------+*/?>