This is my Send_Mail.php :
<?php
// site owner infos
$email_to = 'kaouach.ahmed@gmail.com';
$success_message = "Your message has been successfully sent.";
$site_name = 'Personal Website';
// contact form fields
$name = trim( $_POST['name'] );
$email = trim( $_POST['email'] );
$message = trim( $_POST['message'] );
$submitted = $_POST['submitted'];
// contact form submitted
if ( isset( $submitted ) )
{
// check for error
if ( $name === '' ){
$name_empty = true;
$error = true;}
elseif ... // Checking of others attributs
// If error
if ( isset( $error ) )
{
echo '<div class="alert alert-error contact-alert"><strong>UNSUCCESS! </strong><ul>';
if ($name_empty) {echo '<li>Required</li>';}
elseif ... // same for Other attribute
else{ echo '<li>An error has occurred while sending your message. Please try again later.</li>';}
echo "</ul></div>";
}
// no error, sending mail
if ( ! isset($error) )
{
$subject = 'Contact form message from your ' . $site_name . ' site';
$body = "Name: $name \n\nEmail: $email \n\nMessage: $message";
$headers = 'From: ' . $name . ' <' . $email . '> ' . "\r\n" . 'Reply-To: ' . $email;
mail( $email_to, $subject, $body, $headers );
echo '<div class="alert alert-success contact-alert"><strong>SUCCESS! </strong>' . $success_message . '</div>';
}
}
?>
When I send Mail It show me success message and it's sent, but when I check my gmail box nothing is received. So What's the Problem Over here and how to fix it ? please
Update 2 The problem was not from the php file, anonymous mail sending is not allowed on the server, so how to add the SMTP, username and password attributes to my php file ?