[英]Failed to connect to smtp.gmail.com:587
I am using pear mail library using this error in Yii framework 我正在使用Yii框架中的此错误的梨邮件库
Failed to connect to smtp.gmail.com:587 [SMTP: HELO was not accepted (code: -1, response: )] Error code:10001 无法连接到smtp.gmail.com:587 [SMTP:不接受HELO(代码:-1,响应:)]错误代码:10001
Config file contained 包含的配置文件
'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 phpmailer.php
<?php
include('Mail.php'); 包括( 'Mail.php'); include('Mail/mime.php');
包括( '邮件/ mime.php');
class CZebrostMailer extends CApplicationComponent { 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());
}
}
} }
I am badly stuck please help me out 我被严重卡住,请帮帮我
I got solution of my problem on the same day when i post my question. 我在发布问题的当天就得到了问题的解决方案。 There is only problem is I am sending blank 'helo' to smtp.gmail.com That's why connection is not established.
唯一的问题是我向smtp.gmail.com发送了空白的“ helo”,这就是未建立连接的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.