-1

I am new to PHP and I am trying to write this Form, but it is not sending any Email, whether to my email, nor to the person trying to reserve.

<?php.validate.executablePath
if(empty($_POST['name'])        ||
   empty($_POST['email'])       ||
   empty($_POST['phone'])       ||
   empty($_POST['ankunft'])     ||
   empty($_POST['abreise'])     ||
   empty($_POST['message'])     ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
    echo "No arguments Provided!";
    return false;
   }

$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$ankunft = strip_tags(htmlspecialchars($_POST['ankunft']));
$abreise = strip_tags(htmlspecialchars($_POST['abreise']));
$message = strip_tags(htmlspecialchars($_POST['message']));

// Create the email and send the message
$to = 'myemail@gmail.com'; 
$email_subject = "Website Contact Form:  $name";
$email_body = "You have received a new message from your website.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nAnkunft: $ankunft\n\nAbreise: $abreise\n\nMessage:\n$message";
$headers = "From: myemail@gmail.com\n"; // add noreply Email
$headers .= "Reply-To: $email_address"; 
mail($to,$email_subject,$email_body,$headers);
return true;            
?>

Edit

So I got it working, it was a server issue, but there is still one thing not working, the dates are not working, again I am still new to php we haven't even started it in school yet so I am not sure if this is correct or not.

austriang
  • 31
  • 4

1 Answers1

-1

If you're running a local server such as XAMPP or WAMP, you need to provide credentials for gmail. You can do this in XAMPP by editing the sendmail.ini file to specify your SMTP server and authentication credentials. Like so:

  • locate sendmail.ini in the sendmail directory of XAMPP.
  • find "smtp_server", change its value to "mail.gmail.com"
  • find "auth_username", set it to your email address
  • set "auth_password" to your email password
Dirkmal
  • 76
  • 1
  • 6