1
我試圖發送電子郵件使用梨向Gmail發送郵件,但我有錯誤:梨郵件(Gmail的SMTP) - 無法連接套接字
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:)]
這裏是我的代碼:
<?php
require_once 'Mail.php';
$from = "[email protected]";
$to = "[email protected]";
$subject = "Subject";
$body = "Hello!";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "[email protected]";
$password = "password";
$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 $mail->getMessage();
} else {
echo "Message sent successfully!";
}
?>
我已經閱讀了幾乎所有與我的相同問題,我試過phpmailer,我發現它很難,我試圖刪除擴展= php_openssl.dll在php.ini上找到的意見,重新啓動Apache,改變465至587或所以沒有運氣! Windows防火牆未打開。我究竟做錯了什麼?請幫忙!
謝謝!