ecshop实现smtp发送邮件
程序员文章站
2023-10-30 16:40:34
使用ecshop的smtp方式发送邮件时,在cls_smtp类文件中,执行到get_data方法中的语句:
复制代码 代码如下:
$line &n...
使用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;
}
以上就是本文的全部内容了,希望小伙伴们能够喜欢。
上一篇: 火锅五花肉怎么做好吃
下一篇: 食物相克,鸡蛋和红薯能一起吃吗