当我在GoDaddy上按send时,PHP电子邮件什么也不做


PHP email does nothing when I press send on GoDaddy

我正在运行windows和php5.4的godaddy上托管我的网站,我的联系表格没有发送。这是保存在htdocs/php中的PHPcode。为了让它发挥作用,我已经尝试了几次尝试。

<?php
/*
|--------------------------------------------------------------------------
| Mailer module
|--------------------------------------------------------------------------
|
| These module are used when sending email from contact form
|
*/

/*SECTION I - CONFIGURATION*/
//$receiver_mail = 'youremail@example.com';
$receiver_mail = 'youremail@example.com';
$mail_title = '[Contact Form Submission]';

/*SECTION II - CODE*/
print_r($_POST)
if( !empty($_POST['input-name']) && !empty($_POST['input-mail']) && !empty($_POST['input-message']) )
{
$subject = $mail_title.' message from '.$_POST['input-name'];
$header = 'From: '.$_POST['input-mail'].''r'nReply-To: '.$_POST['input-mail'];
   if ( mail($receiver_mail, $subject, htmlentities($_POST['input-message']), 'From: contactform@thebigbeatsinc.com') )
      $result = "Your message was successfully sent.";
   else
      $result = "Operation could not be completed.";
}
else
{
     $result = "Error processing your request.";
}
//echo $result;
echo "Your message was successfully sent.";
?>

以及HTML:

 <form class="contactForm" action="php/contact.php" method="post" target="_blank">
        <div class="contactFormTitle font1">
            don't be shy, come along & say hi
        </div>
        <fieldset class="contactFormDetails">
            <input type="text" name="input-name" value="" placeholder="Name" />
            <input type="text" name="input-mail" value="" placeholder="Subject" />
        </fieldset>
        <fieldset class="contactFormMessage">
            <textarea rows="" cols="" name="input-message" placeholder="Type your message here"></textarea>
        </fieldset>
        <fieldset class="contactFormButtons">
            <input type="submit" value="Send" />
        </fieldset>
    </form>

您需要添加方法属性:

<form class="contactForm" action="php/contact.php" method="post">

您还应该处理故障排除过程,并更多地关注细节,否则您将在论坛上花费大量时间,试图找出代码不起作用的原因。

对于GoDaddy,from参数需要是您域名下的电子邮件

    if ( mail($receiver_mail, $subject, htmlentities($_POST['input-message']), 'From: contactform@thebigbeatsinc.com') )
        $result = "Your message was successfully sent.";
    else
        $result = "Operation could not be completed.";

您还应该按照Evade Captcha 的规定,将方法帖子添加到您的表单应答器中