0

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 ?

Chlebta
  • 3,090
  • 15
  • 50
  • 99
  • Is there any mail server installed ? for example, sendmail or postfix ? – GBD Jul 09 '14 at 11:54
  • 1
    As a side remark, you do realize you're publishing your email address on a widely visited website, right ? That said, the problem could come from so many places you should debug it step by step : 1) be sure the mail is sent (PHP debug) 2) Be sure it is received and processed by the mail server (logs) 3)Check that it is not considered spam by gmail – Laurent S. Jul 09 '14 at 11:55
  • try to send mail using a transport class like phpmailer etc. and also use mail servers.smtp for gmail is awailable if you intent to use gmail – jayadevkv Jul 09 '14 at 11:56
  • make sure you check "more -> all messages" on the left sidebar on google mail. Google has the tendency to keep emails out of the inbox when an email looks like spam (and a mail server that doesn't match the from address is a big indication of spam) – Gerald Schneider Jul 09 '14 at 11:57
  • Check what does mail( $email_to, $subject, $body, $headers ); return. Check your php.ini configuration http://www.php.net/manual/en/mail.configuration.php . – Maciej Jaśniaczyk Jul 09 '14 at 11:58
  • Please check your apache access/error log to see more details about the error. If you are using wamp server it would be in, C:\wamp\logs\apache_error.log, C:\wamp\logs\access.log – Stranger Jul 09 '14 at 12:06
  • I'm using deploying this directly on my webSite not on localhost – Chlebta Jul 09 '14 at 12:08
  • Always output all errors when you're developing. `error_reporting(E_ALL)` at the top of your file should do the trick, if no server configuration overrides it. – ljacqu Jul 09 '14 at 12:10
  • I got no error my mail is sent but when I check My gmail box nothing is recived – Chlebta Jul 09 '14 at 12:13
  • check your spam folder. – Russell Uhl Jul 09 '14 at 12:24
  • Even In spam, I haven't recived the message – Chlebta Jul 09 '14 at 12:27
  • After Digging I think the error Is in the SMTP configuration, I have to set up the SMTP config into my Php file ? so anyone know how to do it without using phpmailer ? – Chlebta Jul 09 '14 at 14:21

1 Answers1

1

It may be issue of email smtp server. Please be sure the mail server is working perfectly.

Ganesh
  • 162
  • 1
  • 9
  • This is the test Of my SMTP server : http://mxtoolbox.com/SuperTool.aspx?action=smtp%3asmtp.chlebta.com&run=toolpage – Chlebta Jul 09 '14 at 12:41