简体   繁体   中英

PHP Contact Form Problem

http://www.raymondselda.com/php-contact-form-with-jquery-validation/

I'm trying a few different contact forms including the one above.

I have it running on this page: http://themeforward.com/demo2/features/contact-form/

The problem is this form does not successfully send e-mails to the address in the code (finished code can be found here: http://www.raymondselda.com/php-contact-form-with-jquery-validation/ )

Does anybody know what the problem may be?

//If there is no error, send the email
    if(!isset($hasError)) {
        $emailTo = 'youremail@email.com'; //Put your own email address here
        $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments";
        $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

        mail($emailTo, $subject, $body, $headers);
        $emailSent = true;

Many reasons:

  1. Mail isn't configured properly on your server. mail() will return a boolean FALSE if it can't hand off the email to an SMTP server. You're not checking for that condition
  2. The SMTP server isn't configured properly to allow you to send through it
  3. The receiver server has your sending server blacklisted
  4. The email is treated as spam and is getting trashed

First place to start looking is mail()'s return value. Then go look at your SMTP server's log to see what happens to the email (if) once PHP handed it over. The SMTP server's log will also say if the receiving server bounced/refused it.

If it's getting silently thrown in a spam folder on the receiver server, there'll be NO evidence of this on your end, and you'll have to investigate further on the receiving end.

Email is a complicated business with many many invididual steps where each one has to work right. Any glitches anywhere along the line and the email is probably gone. You have to investigate what happens at EACH of these stages to figure out why something isn't being delivered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM