global $globals;
$page->changeTpl('emails/send.tpl');
+ $page->addJsLink('ajax.js');
$page->assign('xorg_title','Polytechnique.org - Envoyer un email');
return join(', ', $ret);
}
+ foreach ($_FILES as &$file) {
+ if ($file['name'] && !PlUpload::get($file, S::v('forlife'), 'emails.send', false)) {
+ $page->trig("Impossible de télécharger '" . pl_entities($file['name']) . "'");
+ }
+ }
+
$to2 = getEmails(Env::v('to_contacts'));
$cc2 = getEmails(Env::v('cc_contacts'));
$txt = str_replace('^M', '', Env::v('contenu'));
$to = Env::v('to');
$subj = Env::v('sujet');
$from = Env::v('from');
- $cc = Env::v('cc');
- $bcc = Env::v('bcc');
+ $cc = trim(Env::v('cc'));
+ $bcc = trim(Env::v('bcc'));
- if (empty($to) && empty($cc) && empty($to2)) {
+ if (empty($to) && empty($cc) && empty($to2) && empty($bcc) && empty($cc2)) {
$page->trig("Indique au moins un destinataire.");
+ $page->assign('uploaded_f', PlUpload::listFilenames(S::v('forlife'), 'emails.send'));
} else {
$mymail = new PlMailer();
$mymail->setFrom($from);
if (!empty($bcc)) { $mymail->addBcc($bcc); }
if (!empty($to2)) { $mymail->addTo($to2); }
if (!empty($cc2)) { $mymail->addCc($cc2); }
- if (is_uploaded_file($_FILES['uploaded']['tmp_name'])) {
- $mymail->addAttachment($_FILES['uploaded']['tmp_name'],
- $_FILES['uploaded']['type'],
- $_FILES['uploaded']['name']);
+ $files =& PlUpload::listFiles(S::v('forlife'), 'emails.send');
+ foreach ($files as $name=>&$upload) {
+ $mymail->addUploadAttachment($upload, $name);
+ }
+ if (Env::v('nowiki')) {
+ $mymail->setTxtBody(wordwrap($txt, 78, "\n"));
+ } else {
+ $mymail->setWikiBody($txt);
}
- $mymail->setTxtBody(wordwrap($txt,72,"\n"));
if ($mymail->send()) {
$page->trig("Ton mail a bien été envoyé.");
$_REQUEST = array('bcc' => S::v('bestalias').'@'.$globals->mail->domain);
+ PlUpload::clear(S::v('forlife'), 'emails.send');
} else {
$page->trig("Erreur lors de l'envoi du courriel, réessaye.");
+ $page->assign('uploaded_f', PlUpload::listFilenames(S::v('forlife'), 'emails.send'));
}
}
} else {
+ PlUpload::clear(S::v('forlife'), 'emails.send');
$_REQUEST['bcc'] = S::v('bestalias').'@'.$globals->mail->domain;
}
WHERE c.uid = {?}
ORDER BY u.nom, u.prenom", S::v('uid'));
$page->assign('contacts', $res->fetchAllAssoc());
+ $page->assign('maxsize', ini_get('post_max_size') . 'o');
}
function handler_broken(&$page, $warn = null, $email = null)