簡體   English   中英

無法連接到smtp.gmail.com:587

[英]Failed to connect to smtp.gmail.com:587

我正在使用Yii框架中的此錯誤的梨郵件庫

無法連接到smtp.gmail.com:587 [SMTP:不接受HELO(代碼:-1,響應:)]錯誤代碼:10001

包含的配置文件

'zebrostMailer' => array(
            'class' => 'application.extensions.zebrostMailer.CZebrostMailer',
            'host' => 'smtp.gmail.com',
            'port' => 587,
            'helo' => '',
            'auth' => true,
            'username' => 'user@gmail.com',
            'password' => '*******',
            'from' => 'TestUser',
            'timeout' => '5',
            'SMTPAuth' => true,
            'SMTPSecure' => 'tls',

        ),

phpmailer.php

<?php

包括( 'Mail.php'); 包括( '郵件/ mime.php');

CZebrostMailer類擴展了CApplicationComponent {

public $host;
public $port;
public $helo;
public $auth;
public $username;
public $password;
public $from;
public $timeout;
public $SMTPAuth;
public $SMTPSecure;
public $Mailer;

public function SendEmail($to, $subject, $body, $htmlImages = null) {
    $mime = new Mail_mime();
    $headers = array(
        'From' => $this->from,
        'To' => $to,
        'Subject' => $subject
    );
    @$mime->setHTMLBody($body);
    if ($htmlImages) {
        foreach ($htmlImages as $htmlImage) {
            $mime->addHTMLImage(
                    $htmlImage, Yii::app()->zebrostGenFuncs->getMimeType($htmlImage)
            );
        }
    }
    $body = @$mime->get();
    $headers = @$mime->headers($headers);
    $smtp = @Mail::factory('smtp', array(
                'host' => $this->host,
                'port' => $this->port,
                'localhost' => $this->helo,
                'auth' => $this->auth,
                'username' => $this->username,
                'password' => $this->password,
                'timeout' => $this->timeout,
                'SMTPSecure' => $this->SMTPSecure,
                'SMTPAuth' => $this->SMTPAuth,

    ));
    if (@PEAR::isError($smtp)) {
        throw new CException(@$smtp->getMessage() . ' Error code:' . @$smtp->getCode());
    }
    $mail = @$smtp->send($to, $headers, $body);
    if (@PEAR::isError($mail)) {
        throw new CException(@$mail->getMessage() . ' Error code:' . @$mail->getCode());
    }
}

}

我被嚴重卡住,請幫幫我

我在發布問題的當天就得到了問題的解決方案。 唯一的問題是我向smtp.gmail.com發送了空白的“ helo”,這就是未建立連接的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM