mardi 26 juillet 2016

PHP Email form not sending emails during offline testing

I have created an email form using a few different tutorials, which incorporates PHP to send the email to my account. However, when I attempt to link this file into my HTML, the file fails to load and I am unable to send emails. How would I fix this issue so the file is incorporated and emails send? It is important to note that I am not hosting this online, all development is being done locally.

HTML for incorporating the file.

<!DOCTYPE HTML>

<!-- PHP Form -->
<?php
    include "contact.php";
?>

PHP

<?php 
if(isset($_POST['submit'])){
$to = "email@example.com"; 
$from = $_POST['email']; 
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];

$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // Sends the user a copy of the message
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
('Location: contact.html');

}
?>




Aucun commentaire:

Enregistrer un commentaire