我需要一些帮助。我正在尝试使用PHP脚本将内容从HTML表单发送到电子邮件。 (我使用xammp localhost作为服务器)。 这些文件是Contacts.html和form-to-email.php。我用不同的电子邮件做了一些测试,但问题并没有解决。我缺少什么想法? 这是我的HTML
<form method="post" name="myemailform" action="form-to-email.php">
<input type="text" name="name" maxlength="30" size="10" class="contact-inputs" placeholder="име"><br>
<input type="email" name="email" maxlength="50" size="10" class="contact-inputs" placeholder="имейл"><br>
<textarea maxlength="1000" rows="6" cols="50" name="message" class="contact-inputs" placeholder="коментар"></textarea><br>
<input class="submit" type="submit" value="Изпрати">
</form>
PHP
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
//Validate first
if(empty($name)||empty($visitor_email))
{
echo "";
exit;
}
if(IsInjected($visitor_email))
{
echo "Name and email are mandatory!";
exit;
}
$email_from = $visitor_email;
$email_subject = "New Form submission";
$email_body = "You received new email from $name.\n".
"with message:\n $message".
//sending email
$to = "georgiev19621962@abv.bg";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done.
header('Location: Contacts.html');
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
问题是我在提交时没有收到来自html表单的内容。我只是没有收到包含电子邮件中内容的消息。