ecshop实现smtp发送邮件
发布:smiling 来源: PHP粉丝网 添加日期:2021-05-09 17:10:52 浏览: 评论:0
这篇文章主要介绍了ecshop实现smtp发送邮件,需要的朋友可以参考下
使用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 = !emptyempty($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;
- }
以上就是本文的全部内容了,希望小伙伴们能够喜欢。
Tags: ecshop发送邮件 smtp发送邮件
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)