1

我的页面 php 代码是这样的

`

   require_once "Mail.php";

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

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "pramodkumar.damam73@gmail.com";  //<> give errors
    $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>");
     }

?>`

最初它显示了许多错误,说 isError 和 send 函数不是静态的。所以我将 PEAR.php 和 Mail.php 的函数修改为静态的。但是现在我遇到了错误

Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (code: -1, response: )]

请解决我的问题。

4

0 回答 0