require_once "Mail.php";
error_reporting(E_ALL ^ E_STRICT);
$mail_To = $email;
$mail_Subject = "Reservation notification From Tamera Plaza Inn";
$mail_Body = "First Name: $name\n".
"Last Name: $last\n".
"Email: $email \n".
"City: $city \n".
"Zip Code: $zip \n".
"Country: $country \n".
"Contact Number: $cnumber \n".
"Password: $password \n".
"Check In: $arrival\n ".
"Check Out: $departure\n ".
"Number of Adults: $adults\n ".
"Number of child: $child\n ".
"Total nights of stay: $result\n ".
"Room Type: $type\n ".
"Number of rooms: $nroom\n ".
"Payable amount: $payable\n ".
"Confirmation Number: $confirmation\n ";
$host = "localhost";
$username = "";
$password = "";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($mail_To, $mail_Subject, $mail_Body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
如您所见,上面的代码用于发送电子邮件。这就是我的网络试图做的事情,但有一件事阻碍了我的成功是下面的错误。我似乎无法连接到我的邮件服务器,这是PEAR。我在这里错过了什么吗?
ERROR:
Failed to connect to localhost:25 [SMTP: Failed to connect socket: No connection could be made because the target machine actively refused it. (code: -1, response: )]
顺便说一下,我正在使用Wampserver
答案 0 :(得分:0)
No connection could be made because the target machine actively refused it.
这是您的问题,如错误消息中所述。检查邮件服务器的防火墙设置。