【发布时间】:2014-07-27 07:01:57
【问题描述】:
我无法发送邮件,有人可以帮忙吗?我尝试在 google 上冲浪,但仍然没有答案。 我正在使用名为 XAMPP 的应用程序,这可能是它的原因吗? XAMPP 是否具备所有 php 功能?
这是mailform.php
<?php
$to = "ratisharabidze@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "ratisharabidze@yahoo.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
这是一个form.html
<html>
<body>
<?php
function spamcheck($field)
{
//eregi() performs a case insensitive regular expression match
if(eregi("to:",$field) || eregi("cc:",$field))
{
return TRUE;
} else
{
return FALSE;
}
} //if "email" is filled out, send email
if (isset($_REQUEST['email']))
{
//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==TRUE)
{
echo "Invalid input";
}
else
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", "Subject: $subject", $message, "From: $email" );
echo "Thank you for using our mail form";
}
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br />
<input type='submit' />
</form>";
?>
</body>
</html>
【问题讨论】:
-
你在你的 xampp 上打开 apache 了吗?