【发布时间】:2014-07-26 13:07:12
【问题描述】:
我想从本地主机发送一封包含 mail.php 文件的 php 电子邮件。
这是我的 test.php 文件代码:
<?php
include_once("Mail.php");
$From = "Sender's name <testing123xyz@gmail.com>";
$To = "Recipient's name <test2@gmail.com>";
$Subject = "Send Email using SMTP authentication";
$Message = "This example demonstrates how you can send email with PHP using SMTP authentication";
$Host = "mail.gmail.com";
$Username = "testing123xyz";
$Password = "testing";
// Do not change bellow
$Headers = array ('From' => $From, 'To' => $To, 'Subject' => $Subject);
$SMTP = Mail::factory('smtp', array ('host' => $Host, 'auth' => true,
'username' => $Username, 'password' => $Password));
$mail = $SMTP->send($To, $Headers, $Message);
if (PEAR::isError($mail)){
echo($mail->getMessage());
} else {
echo("Email Message sent!");
}
?>
当我点击 test.php 文件的 url 时,服务器抛出以下错误:
无法连接到 smtp.gmail.com:25 [SMTP:无法连接套接字:无法建立连接,因为目标机器主动拒绝了它。 (代码:-1,响应:)]
请帮帮我。 谢谢。
【问题讨论】: