You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

<?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>');
}
}
?>