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'])); //-- $user_answer = htmlspecialchars(trim($_POST['user_answer'])); $answer = htmlspecialchars(trim($_POST['answer'])); //-- $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 && substr(md5($user_answer),5,10) === $answer) { $mail = new SimpleMail(); // $headers = "From: contact@echosystem.fr"; $mailpage = file_get_contents("mail.txt.html"); // $mail->setHtml($); // $mailpage2 = "". $mailpage. ""; // $subject = "confirmation: message enregistrer"; // mail($email,$subject,$mailpage2,$headers); $mail->setTo($email); $mail->setFrom("contact@echosystem.fr"); $mail->setSender($name); $mail->setSubject("confirmation: message enregistrer"); $mail->setHtml($mailpage); $mail->send(); $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 = "
Echosystem.fr.
{$config->get('fields.name')}: {$name}
{$config->get('fields.email')}: {$email}
{$config->get('fields.message')}: {$message}
"; $mail->setHtml($body); $mail->send(); $emailSent = true; } else { $hasError = true; } } ?>