php邮件脚本不起作用

时间:2016-09-30 16:41:13

标签: php html forms

我正在使用以下脚本通过我的网站发送的电子邮件与我们联系。

  

但是脚本无效,收到Error sending mail消息。

没有得到这里的问题:

<?php 
$MailToAddress = "ToEmailID"; 
$redirectURL = "index.html"; 
$MailSubject = "Inquiries - Contact Us"; 
$redirectURL = "index.html";
$message_body = "NAME: ".$_POST["name"]."\r\n"; 
$message_body .= "E-Mail: ".$_POST["email"]."\r\n";
$message_body .= "SUBJECT: ".$_POST["subject"]."\r\n";
$message_body .= "MESSAGE: ".$_POST["message"]."\r\n";

if (!mail($MailToAddress, $MailSubject, $message_body)) {
    echo "Error sending e-mail!";
}
else {
    header("Location: ".$redirectURL);
}     
?> 

以下是表格:

<form action="submit.php" class="contact-form" method="post">
    <div class="col-md-4"><input id="senderName" name="name" placeholder="name" type="text" /></div>
    <input id="senderEmail" name="email" placeholder="email address" type="text" />
    <input id="subject" name="subject" placeholder="subject" type="text" />
    <textarea id="message" name="message" placeholder="Message" required="" rows="6"></textarea>
    <input class="btn-regular alignleft contact_button" type="submit" value="SUBMIT" name="submit">
</form>

0 个答案:

没有答案