1

My page php code is this

`

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

?>`

Initially it shown many errors saying isError and send functions are not static. So I modified PEAR.php and Mail.php's functions as static. But now I am getting error like

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: )]

Please fix my problem.

  • 1
    Make sure that `openssl` extension is enabled. – Rikesh May 27 '13 at 05:34
  • Also note that google uses tls ... see http://stackoverflow.com/questions/7038580/send-mail-with-zend-mail-through-gmail-smtp-server for zend framework implementation. – Orangepill May 27 '13 at 05:35
  • You can ignore the PEAR Mail static errors, most PEAR modules were not updated for PHP 5.4 – Uberfuzzy May 27 '13 at 06:00

0 Answers0