I am using pear mail library using this error in Yii framework
Failed to connect to smtp.gmail.com:587 [SMTP: HELO was not accepted (code: -1, response: )] Error code: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
<?php
include('Mail.php'); include('Mail/mime.php');
class CZebrostMailer extends 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.