我在服务器上安装了 Pear,然后安装了 Mail 和 SMTP 组件。然后我将我的 php.ini 文件更新为 "include_path = ".C:\wamp\bin\php\php5.4.3\pear" 因为那是 Mail.php 所在的位置。由于某种原因,当我通过网络浏览器我收到以下错误。
Warning: require_once(Mail.php): failed to open stream: No such file or directory in C:\wamp\www\email.php on line 3
和:
Fatal error: require_once(): Failed opening required 'Mail.php' (include_path='.;C:\php\pear') in C:\wamp\www\email.php on line 3
我对 PHP 还很陌生,上周之前我什至从未听说过梨,因为我通常设置一个交换服务器。任何帮助,将不胜感激。下面是测试脚本。
<?php
require_once "Mail.php";
$from = "Ty Jacobs <FROM_EMAIL>";
$to = "Ty Jacobs <TO_EMAIL>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.bizmail.yahoo.com";
$port = "465";
$username = "MYUSERNAME";
$password = "MYPASSWORD";
$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>");
}
?>
PHP.INI 文件:
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
include_path=".;C:\wamp\bin\php\php5.4.3\pear"