I want to send an email with PHP when the user completes the HTML form, then sends the form information by email. I want to do the same site view script with the template.
I found this code but the message was not sent
< ?php
if (isset($_POST['submit'])) {
$to = $_POST['email'];
$subject = $_POST['name'];
$message = getRequestURI();
$from = "programmer@example.com";
$headers = "From:" . $from;
if (mail($to, $subject, $message, $headers)) {
echo "Mail Sent.";
}
else {
echo "failed";
}
} ?>
Emmanuel
18 janvier 2019
Répondre
MP
Check the manual : http://php.net/manual/en/function.mail.php
I found this code but the message was not sent
< ?php
if (isset($_POST['submit'])) {
$to = $_POST['email'];
$subject = $_POST['name'];
$message = getRequestURI();
$from = "programmer@example.com";
$headers = "From:" . $from;
if (mail($to, $subject, $message, $headers)) {
echo "Mail Sent.";
}
else {
echo "failed";
}
} ?>