简体   繁体   中英

PHP Pear Mail help

this is my code

    $from = "Whatever<whatever@gmail.com>";
    $to = "whatever<whatever@hotmail.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "whatever@gmail.com";
    $password = "whatever";

    $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>");
     }

?>  

The error i get is : Warning: require_once(PEAR.php) [function.require-once]: failed to open stream: No such file or directory in /home/pedurc5m/php/Mail.php on line 46

Fatal error: require_once() [function.require]: Failed opening required 'PEAR.php' (include_path='/home/pedurc5m/php/') in /home/pedurc5m/php/Mail.php on line 46 My shared host web server says that

Location of Your PHP Extension(s) and Application(s)

Path: /home/pedurc5m/php

Why am i getting an error ? I'm VERY new to PHP,thanks for all the help!

这意味着PEAR.php不在此路径/ home / pedurc5m / php /

It looks like you don't have PEAR installed or don't have the Mail module. Look here for how to setup PEAR on your host. Once you setup PEAR, install the Mail module and your code should work. (In the linked page scroll down and look for 'PEAR in hosting environments')

Can you post the full script please? (with your requires and includes?) The way PHP finds dependencies is

1) They are explicitly declared at top of your script - full path to whatever class/function you need

2) Your php.ini include_path settings - I believe that should be correct in your case.

3) Your custom class loader via __autoload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM