Ecshop implementing SMTP Send mail _php instances

Source: Internet
Author: User
When you send a message by using Ecshop SMTP, in the Cls_smtp class file, execute the statement in the Get_data method:

Copy the Code code as follows:
$line = fgets ($this->connection, 512);

A time-out error occurred.

Commenting out the execution of the function and sending the message directly, the error EHLO command failed is returned.

But when I print out the linked data, it's really connected.

Before sending a message with another program can be sent normally, and then resend the function, instead of using Phpmailer to send mail.

Copy CodeThe code is as follows:
function Smtp_mail ($name, $email, $subject, $content, $type = 1, $notification =false) {
/* If message encoding is not ec_charset, create character set conversion object, convert code */
if ($GLOBALS [' _cfg '] [' mail_charset ']! = Ec_charset)
{
$name = Ecs_iconv (Ec_charset, $GLOBALS [' _cfg '] [' mail_charset '], $name);
$subject = Ecs_iconv (Ec_charset, $GLOBALS [' _cfg '] [' mail_charset '], $subject);
$content = Ecs_iconv (Ec_charset, $GLOBALS [' _cfg '] [' mail_charset '], $content);
$shop _name = Ecs_iconv (Ec_charset, $GLOBALS [' _cfg '] [' mail_charset '], $GLOBALS [' _cfg '] [' shop_name ']);
}
$charset = $GLOBALS [' _cfg '] [' mail_charset '];
Include_once Root_path. ' includes/phpmailer/class.phpmailer.php ';
$mail = new Phpmailer ();
$mail->from = $GLOBALS [' _cfg '] [' smtp_user '];
$mail->fromname = ' Yunnan * * * Broadcast Co., Ltd. ';
if ($GLOBALS [' _cfg '] [' mail_service '] = = 0) {
$mail->ismail ();
} else {
$mail->issmtp ();
$mail->host = $GLOBALS [' _cfg '] [' smtp_host '];
$mail->port = $GLOBALS [' _cfg '] [' smtp_port '];
$mail->smtpauth =!empty ($GLOBALS [' _cfg '] [' smtp_pass ']);
$mail->username = $GLOBALS [' _cfg '] [' smtp_user '];
$mail->password = $GLOBALS [' _cfg '] [' smtp_pass '];
}
$mail->encoding = "base64";
$mail->priority = $this->priority;
$mail->charset = $charset;
$mail->ishtml ($type);
$mail->subject = $subject;
$mail->body = $content;
$mail->timeout = 30;
$mail->smtpdebug = false;
$mail->clearaddresses ();
$mail->addaddress ($email, $name);
$mail->confirmreadingto = $notification;
$res = $mail->send ();
if (! $res)
{
$GLOBALS [' Err ']->add ($mail->errorinfo);
$GLOBALS [' Err ']->add ($GLOBALS [' _lang '] [' sendemail_false ']);
return false;
}
return true;
}

The above is the whole content of this article, I hope that small partners can enjoy.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.