从表单发送邮件时出现错误
无法在“mail.yoursite.com”端口 25 连接到邮件服务器,请在 php.ini 中验证您的“SMTP”和“smtp_port”设置或在线使用 C:\xampp\xampp\htdocs\send.php 中的 ini_set() 8
警告:mail() [function.mail]:SMTP 服务器响应:第 9 行 C:\xampp\xampp\htdocs\send.php 中的 550 ACCESS DENIED
消息传递失败...
这是代码
邮件.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="send.php" action="POST">
Enter Name : <input type="text" name="name" />
Enter E-Mail : <input type="text" name="email" />
Enter Subject: <input type="text" name="subject" />
Enter Message: <input type="text" name="mess" />
<input type="submit" name="Submit" />
</form>
<?php
?>
</body>
</html>
send.php
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$body = $_POST['subject'];
$message=$_POST['message'];
//ini_set("sendmail_from","name@yoursite.com");
//ini_set("SMTP","mail.yoursite.com");
mail("name@yoursite.com", $name, $message, "From :$from");
if (mail('nishantmshah@gmail.com', $name, $body, $message, "From :$from")) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>