我正在使用Yii框架中出现此错误的pear邮件库
无法连接到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
include('Mail.php'); include('Mail / 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());
}
}
}
我严重卡住了,请帮帮我
答案 0 :(得分:1)
发布问题的当天,我就解决了问题。 唯一的问题是我正在向smtp.gmail.com发送空白“ helo” 这就是为什么未建立连接的原因。