PHP警告:require(Mail.php):无法打开流:/ home /中没有这样的文件或目录

问题描述 投票:0回答:2

我正在使用Mochahost,我已经从Pear安装了Mail。现在我不知道它在哪里安装了这些文件。

请指导我存储已安装文件的位置。

当我使用以下代码时,它给我以下错误消息。

      PHP Warning:  require(Mail.php): failed to open stream: 
No such file or directory in /home/

错误消息很明显,因为我没有在我的应用程序文件夹中添加任何文件。

以下是我关注的代码。

请指导我如何包含'Mail.php'文件的路径。

<?php

//require_once "Mail.php";
require "Mail.php";



$from = "Taha <[email protected]>";


$to = "Taha <[email protected]>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";



$host = "111.11.11.111";

$username = "[email protected]";

$password = "password";



$headers = array ('From' => $from,


  'To' => $to,

  'Subject' => $subject);



 $port = "2525";

 $smtp = Mail::factory('smtp',

  array ('host' => $host,

    'port' => $port,

    'auth' => true,

    'username' => $username,


    'password' => $password)); 

$mail = $smtp->send($to, $headers, $body);

echo "PEAR before";

if (PEAR::isError($mail)) {

  echo("<p>" . $mail->getMessage() . "</p>");


 } else {

  echo("<p>Message successfully sent!</p>");

 }
php email smtp
2个回答
0
投票

包括它:

<?php include 'home/username/php/Mail.php' ; ?>

0
投票

检查include_path中是否有pear目录

php -r "echo get_include_path();"

如果不是,你必须将它包含在你的php.ini上,或直接在你的代码上添加它

<?php 
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
© www.soinside.com 2019 - 2024. All rights reserved.