如何包含使用PHP Pear Mail的mail.php。我使用下面的代碼test.php的文件:如何使用php pear郵件
require_once "Mail.php";
$from = "<[email protected]>";
$to = "<[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "<[email protected]>";
$password = "testtest";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
,並遇到了以下錯誤通過這個代碼:
Warning: require_once(Mail.php) [function.require-once]: failed to open stream: No such file or directory in D:\Hosting\6525150\html\test.php on line 3
Fatal error: require_once() [function.require]: Failed opening required 'Mail.php' (include_path='.;C:\php5\pear') in D:\Hosting\6525150\html\test.php on line 3
誰能告訴我是什麼問題?
pear安裝在我的服務器上。並且包含路徑爲「C:\ php5 \ pear」 – Deepa
您還需要安裝Mail軟件包 –
還使用phpinfo()檢查php include_path; –