gpt4 book ai didi

php - Pear Mail "Unable to find class for driver smtp"找不到文件,就在那里

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:32:40 27 4
gpt4 key购买 nike

我的 VPS 运行的是 CentOS 5.3。我已经安装了 pear、Mail 和 Net_Mail。当我尝试发送邮件时,我得到“无法找到驱动程序 smtp 的类”。我查看了 Mail.php,发现我的 pear 目录中需要一个“Mail/smtp.php”,它是存在的。我验证了 php 包含目录,并通过 chown 将所有权限重置为 apache。我查了一下chmod,都是644。

我的代码:

    $from = "Admin <admin@myemail.com>";
$to = "New User <".$email.">";
$subject = "Welcome to MyEmail!";
$body = "Thanks for choosing <MyEmail>! We strive to provide 24/7 email service and support. If you have ANY issues, concerns, etc, please reply to this email, or simply compose a new one to: myemail@email.com !";
$host = "localhost";
$username = "username";
$password = "password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
if (PEAR::isError($smtp)) {
echo("<p>" . $smtp->getMessage() . "</p>");
}
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}

最佳答案

当在开头添加 require_once 'Mail.php'; 时,您提供的代码在这里有效。

Mail/smtp.php 文件在您的服务器上是什么 md5 散列?它是否包含 class Mail_smtp 行?

这里是:479aa21ec86e63e629db646ed292b142(通过md5sum/usr/share/php/Mail/smtp.php)

关于php - Pear Mail "Unable to find class for driver smtp"找不到文件,就在那里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24337277/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com