我無法發送郵件,任何人都可以幫助它嗎?我試圖在Google上衝浪,但我仍然沒有答案。 我正在使用名爲XAMPP的應用程序,它可能是它的原因嗎? XAMPP是否具有所有的php功能?使用php使用xampp發送郵件
這是mailform.php
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$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("[email protected]", "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? –