0

我有以下代码

 phpinfo();

       $mail = new PHPMailer();
        $mail->IsSMTP();  // telling the class to use SMTP
        $mail->SMTPSecure = "ssl";
        $mail->Host     = "smtp.gmail.com"; // SMTP server
        $mail->Port = 465;


            $mail->SMTPAuth = true; 
            $mail->Username= 'someone@gmail.com';
            $mail->Password='xxx';
            $mail->From  = "someone@gmail.com";
            $mail->AddAddress("abc@gmail.com");

            $mail->Subject  = "First PHPMailer Message";
            $mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
            $mail->WordWrap = 50;
        if(!$mail->Send()) {
          echo 'Message was not sent.';
          echo 'Mailer error: ' . $mail->ErrorInfo;
        } else {
          echo 'Message has been sent.';
        }

我还在 php.ini 文件中启用了“extension=php_openssl.dll”。

但它仍然给我一个错误,

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)

Mailer error: SMTP Error: Could not connect to SMTP host.

虽然我extension=php_openssl.dll在我的 php.ini 文件中启用了 phpinfo(); 表明这OpenSSL support:disabled (install ext/openssl)怎么可能?

谁能帮忙??

4

3 回答 3

0

试试下面的例子:

http://www.xtreemhost.com/2010/04/11/how-to-send-e-mails-via-smtp-with-phpmailer-and-gmail/

于 2012-07-09T10:34:17.453 回答
0
$mail->SMTPSecure = "ssl";

我有这个问题。检查您的 PHPMailer 版本是否是最新的

于 2012-07-09T07:04:32.707 回答
0

这意味着您的 ssl 模块未正确编译,或者已编译但未通过 php.ini 配置文件启用。

检查您的设置以确保您已启用它。

于 2012-07-09T07:14:05.920 回答