使用ECShop的smtp方式發送郵件時,在cls_smtp類文件中,執行到get_data方法中的語句:
復制代碼 代碼如下:
$line = fgets($this->connection, 512);
;時,發生超時錯誤。
注釋掉該函數的執行,直接發送郵件,則返回錯誤ehlo command failed。
但打印出鏈接數據時,確實連上了。
之前用別的程序發送郵件也是可以正常發送的,於是重新發送函數,改用phpmailer發送郵件。
復制代碼 代碼如下:
function smtp_mail($name, $email, $subject, $content, $type = 1, $notification=false) {
/* 如果郵件編碼不是EC_CHARSET,創建字符集轉換對象,轉換編碼 */
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;
}
以上就是本文的全部內容了,希望小伙伴們能夠喜歡。