generated from Templates_CodeFirst/templateHtmlCss
ajout de la gestion des mails dans la partie contact 💥
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
e1f0bc17b0
commit
a566503c4b
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
require_once "Mail.php";
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
|
||||||
|
$surname = filter_input(INPUT_POST, 'surname', FILTER_SANITIZE_STRING);
|
||||||
|
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
|
||||||
|
$message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
|
if ($name && $surname && $email && $message) {
|
||||||
|
$from = $email;
|
||||||
|
$to = '<cailloux.p03@gmail.com>';
|
||||||
|
$subject = 'Nouveau message du Pifolio !';
|
||||||
|
$body = "Nom: $name $surname\n\nE-mail: $email\n\nMessage:\n$message";
|
||||||
|
|
||||||
|
$headers = array(
|
||||||
|
'From' => $from,
|
||||||
|
'To' => $to,
|
||||||
|
'Subject' => $subject
|
||||||
|
);
|
||||||
|
|
||||||
|
$smtp = Mail::factory('smtp', array(
|
||||||
|
'host' => 'ssl://smtp.gmail.com',
|
||||||
|
'port' => '465',
|
||||||
|
'auth' => true,
|
||||||
|
'username' => 'cailloux.p03@gmail.com',
|
||||||
|
'password' => 'passwordxxx' // Replace with your email password
|
||||||
|
));
|
||||||
|
|
||||||
|
$mail = $smtp->send($to, $headers, $body);
|
||||||
|
|
||||||
|
if (PEAR::isError($mail)) {
|
||||||
|
echo('<p>' . $mail->getMessage() . '</p>');
|
||||||
|
} else {
|
||||||
|
echo('<p>Message successfully sent!</p>');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo('<p>Invalid input. Please check your details and try again.</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in new issue