I need to add to this php code validation smtp of gmail or my own domain, I do not know how to do it since this form I got it on the net and I am beginning to familiarize myself with the php language. Thank you!
/* Set e-mail recipient */
$myemail = "[email protected]";
$subject = "email title";
/* Check all form inputs using check_input function*/
$name = check_input($_POST['name'], "Favor de ingresar su nombre");
$company = check_input($_POST['company']);
$telephone = check_input($_POST['telephone'], "Favor de ingresar su telefono.");
$email = check_input($_POST['email']);
$message = check_input($_POST['message'], "Favor de escribir un mensaje.");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("El correo que escribio no es valido.");
}
/* Let's prepare the message for the e-mail */
$message = "
Este mensaje fue enviado desde su sitio www.mysite.mx:
Nombre: $name
Empresa: $company
Telefono: $telephone
E-mail: $email
Mensaje:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: index2.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>