這篇文章主要介紹了ecshop實(shí)現(xiàn)smtp發(fā)送郵件,需要的朋友可以參考下
使用ECShop的smtp方式發(fā)送郵件時(shí),在cls_smtp類文件中,執(zhí)行到get_data方法中的語句:
代碼如下:
$line = fgets($this->connection, 512);
;時(shí),發(fā)生超時(shí)錯誤。
注釋掉該函數(shù)的執(zhí)行,直接發(fā)送郵件,則返回錯誤ehlo command failed。
但打印出鏈接數(shù)據(jù)時(shí),確實(shí)連上了。
之前用別的程序發(fā)送郵件也是可以正常發(fā)送的,于是重新發(fā)送函數(shù),改用phpmailer發(fā)送郵件。
代碼如下:
function smtp_mail($name, $email, $subject, $content, $type = 1, $notification=false) {
/* 如果郵件編碼不是EC_CHARSET,創(chuàng)建字符集轉(zhuǎn)換對象,轉(zhuǎn)換編碼 */
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 = '云南***播有限公司';
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;
}
以上就是本文的全部內(nèi)容了,希望小伙伴們能夠喜歡。
更多信息請查看IT技術(shù)專欄