From 6ff4f8c0ff2e02e07b1f45793a5db3b306d50813 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Fri, 13 Nov 2009 10:41:29 +0100 Subject: [PATCH 1/1] Notifies the user when an email is not valid. --- modules/email.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/email.php b/modules/email.php index 272756f..0898aa4 100644 --- a/modules/email.php +++ b/modules/email.php @@ -424,8 +424,20 @@ class EmailModule extends PLModule $cc = str_replace(';', ',', Env::t('cc')); $bcc = str_replace(';', ',', Env::t('bcc')); + $email_regex = '/^[a-z0-9.\-+_\$]+@([\-.+_]?[a-z0-9])+$/i'; + foreach (explode(',', $to . ',' . $cc . ',' . $bcc) as $email) { + $email = trim($email); + if ($email != '' && !preg_match($email_regex, $email)) { + $page->trigError("L'adresse email " . $email . ' est erronée.'); + $error = true; + } + } if (empty($to) && empty($cc) && empty($to2) && empty($bcc) && empty($cc2)) { $page->trigError("Indique au moins un destinataire."); + $error = true; + } + + if ($error) { $page->assign('uploaded_f', PlUpload::listFilenames(S::user()->login(), 'emails.send')); } else { $mymail = new PlMailer(); -- 2.1.4