9661be0b6749b0c4df5b6a11b6ec7a40060a4503
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once("xorg.inc.php");
23 new_skinned_page('emails/send.tpl',AUTH_MDP
);
25 // action si on recoit un formulaire
26 if (Env
::get('submit') == 'Envoyer')
28 $to2 = join(', ', Env
::getMixed('contacts', Array()));
29 $txt = str_replace('^M', '', Env
::get('contenu'));
31 $subj = Env
::get('sujet');
32 $from = Env
::get('from');
34 $bcc = Env
::get('bcc');
36 if (empty($to) && empty($cc) && empty($to2)) {
37 $page->trig("Indique au moins un destinataire.");
39 require_once("diogenes/diogenes.hermes.inc.php");
41 $mymail = new HermesMailer();
42 $mymail->setFrom($from);
43 $mymail->setSubject($subj);
44 if (!empty($to)) { $mymail->addTo($to); }
45 if (!empty($cc)) { $mymail->addCc($cc); }
46 if (!empty($bcc)) { $mymail->addBcc($bcc); }
47 if (!empty($to2)) { $mymail->addTo($to2); }
48 $mymail->setTxtBody(wordwrap($txt,72,"\n"));
49 if ($mymail->send()) {
50 $page->trig("Ton mail a bien été envoyé.");
51 $_REQUEST = array('bcc' => Session
::get('bestalias').'@'.$globals->mail
->domain
);
53 $page->trig("Erreur lors de l'envoi du courriel, réessaye.");
57 $_REQUEST['bcc'] = Session
::get('bestalias').'@'.$globals->mail
->domain
;
60 $res = $globals->xdb
->query(
61 "SELECT u.prenom, u.nom, u.promo, a.alias as forlife
62 FROM auth_user_md5 AS u
63 INNER JOIN contacts AS c ON (u.user_id = c.contact)
64 INNER JOIN aliases AS a ON (u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
66 ORDER BY u.nom, u.prenom", Session
::getInt('uid'));
67 $page->assign('contacts', $res->fetchAllAssoc());