Home > Backend Development > PHP Tutorial > ecshop implements smtp to send emails_PHP tutorial

ecshop implements smtp to send emails_PHP tutorial

WBOY
Release: 2016-07-13 10:08:05
Original
941 people have browsed it

ecshop implements smtp to send emails

This article mainly introduces ecshop to implement smtp to send emails. Friends who need it can refer to it

When using ECShop’s SMTP method to send emails, in the cls_smtp class file, execute the statement in the get_data method:

The code is as follows:

$line = fgets($this->connection, 512);

;;A timeout error occurred.

Comment out the execution of this function and send the email directly, the error ehlo command failed will be returned.

But when the link data is printed out, it is indeed connected.

I could send emails normally using other programs, so I resend the function and use phpmailer to send emails.

The code is as follows:

Function smtp_mail($name, $email, $subject, $content, $type = 1, $notification=false) {

/* If the email encoding is not EC_CHARSET, create a character set conversion object and convert the encoding */

 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 *** Broadcasting 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 entire content of this article, I hope you guys will like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/952850.htmlTechArticleecshop implements smtp to send emails. This article mainly introduces ecshop to implement smtp to send emails. Friends who need it can refer to it. When ECShop uses SMTP to send emails, in the cls_smtp class file...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template