<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: yoursite.com';
$to = 'contact@yoursite.com';
$subject = 'Customer Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
我试过创建一个简单的邮件表单。表单本身在我的 index.html
页面上,但它提交到一个单独的“感谢您的提交”页面 thankyou.php
,其中嵌入了上述 PHP 代码。
代码提交完美,但从来没有发送电子邮件。我该如何解决这个问题?