我正在使用php邮件程序从smtp服务器发送邮件。所以现在我有这样的代码 在index.html代码中就像这样
<form method="post" action="email.php">
Email: <input name="email" id="email" type="text" /><br />
Message:<br />
<textarea name="message" id="message" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
并在email.php中我已经包含了php邮件文件。所以我的代码就像这样
<?php
require("class.PHPMailer.php");
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
// When we unzipped PHPMailer, it unzipped to
// public_html/PHPMailer_5.2.0
require("lib/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//s$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.testmail.com";
$mail->Port = 25; // or 587
$mail->IsHTML(true);
$mail->Username = "mail@testname.com";
$mail->Password = "XXCCGGHHTT";
//$mail->SetFrom("myname@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("anothernae@gmail.com");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
但是当我提交它的显示错误时,如
SMTP ERROR: Failed to connect to server: Connection refused (111) SMTP connect() failed. Mailer Error: SMTP connect() failed.
所以可以告诉我这里的错误是什么?如何解决这个问题?