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
);
24 $page->assign('xorg_title','Polytechnique.org - Envoyer un email');
26 // action si on recoit un formulaire
27 if (Env
::get('submit') == 'Envoyer')
29 $to2 = join(', ', Env
::getMixed('contacts', Array()));
30 $txt = str_replace('^M', '', Env
::get('contenu'));
32 $subj = Env
::get('sujet');
33 $from = Env
::get('from');
35 $bcc = Env
::get('bcc');
37 if (empty($to) && empty($cc) && empty($to2)) {
38 $page->trig("Indique au moins un destinataire.");
40 require_once("diogenes/diogenes.hermes.inc.php");
42 $mymail = new HermesMailer();
43 $mymail->setFrom($from);
44 $mymail->setSubject($subj);
45 if (!empty($to)) { $mymail->addTo($to); }
46 if (!empty($cc)) { $mymail->addCc($cc); }
47 if (!empty($bcc)) { $mymail->addBcc($bcc); }
48 if (!empty($to2)) { $mymail->addTo($to2); }
49 $mymail->setTxtBody(wordwrap($txt,72,"\n"));
50 if ($mymail->send()) {
51 $page->trig("Ton mail a bien été envoyé.");
52 $_REQUEST = array('bcc' => Session
::get('bestalias').'@'.$globals->mail
->domain
);
54 $page->trig("Erreur lors de l'envoi du courriel, réessaye.");
58 $_REQUEST['bcc'] = Session
::get('bestalias').'@'.$globals->mail
->domain
;
61 $res = $globals->xdb
->query(
62 "SELECT u.prenom, u.nom, u.promo, a.alias as forlife
63 FROM auth_user_md5 AS u
64 INNER JOIN contacts AS c ON (u.user_id = c.contact)
65 INNER JOIN aliases AS a ON (u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
67 ORDER BY u.nom, u.prenom", Session
::getInt('uid'));
68 $page->assign('contacts', $res->fetchAllAssoc());