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.