register(); $mailLoader->register(); use Helpers\Config; use SimpleMail\SimpleMail; $config = new Config; $config->load('./config/config.php'); //check secu code $number_1 = rand(1, 9); $number_2 = rand(1, 9); $answer = substr(md5($number_1+$number_2),5,10); // if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = stripslashes(trim($_POST['form-name'])); $email = stripslashes(trim($_POST['form-email'])); $phone = stripslashes(trim($_POST['form-phone'])); $subject = stripslashes(trim($_POST['form-subject'])); $message = stripslashes(trim($_POST['form-message'])); $pattern = '/[\r\n]|Content-Type:|Bcc:|Cc:/i'; if (preg_match($pattern, $name) || preg_match($pattern, $email) || preg_match($pattern, $subject)) { die("Header injection detected"); } $emailIsValid = filter_var($email, FILTER_VALIDATE_EMAIL); if ($name && $email && $emailIsValid && $subject && $message) { $mail = new SimpleMail(); $mail->setTo($config->get('emails.to')); $mail->setFrom($config->get('emails.from')); $mail->setSender($name); $mail->setSubject($config->get('subject.prefix') . ' ' . $subject); $body = "
{$config->get('fields.name')}: {$name}
{$config->get('fields.email')}: {$email}
{$config->get('fields.phone')}: {$phone}
{$config->get('fields.message')}: {$message}
"; $mail->setHtml($body); $mail->send(); $emailSent = true; } else { $hasError = true; } } ?>Echosystem.fr.