I'm having some issues with a php email handler. I've used the same script before, but for some reason it won't send the email. Any help is greatly appreciated. This is the html form with the fields I require and labels. HTML:
<form class="flat white vertical corporate-lead-form" method="POST" form action="php/mail-handler.php">
<label for="name">Nombre Completo</label>
<input id="name" type="text" name="name" maxlength="30" autocomplete="off" required />
<label for="phone">Teléfono</label>
<input id="phone" type="text" name="phone" maxlength="30" autocomplete="off" required />
<label for="email-adress">Email</label>
<input id="email-adress" type="text" name="email-adress" maxlength="30" autocomplete="off" required />
<label for="location">Ciudad</label>
<input id="location" type="text" name="location" maxlength="30" autocomplete="off" required />
<label for="comments">Comentarios</label>
<textarea name="comments" id="comments" rows="2" cols="20" required="required"></textarea>
<input type="submit" name="submit" id="submit" value="Enviar" />
</form>
This is the form handler file I used PHP:
<?php
$errors = '';
$myemail = 'eduardo@portafoliobranding.com';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$location = $_POST['location'];
$comments = $_POST['comments'];
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n Email: $email_address \n Tel: \n $phone \n Ubicación: \n $location \n Comentarios: \n $comments";
}
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header("Location: /index.html");
exit();
?>