春叔哥 發表於 2023-5-22 00:00:00

ecshop实现smtp发送邮件

<p>
使用ECShop的smtp方式发送邮件时,在cls_smtp类文件中,执行到get_data方法中的语句:</p>
<p>
 </p>
<div>
<span><u>复制代码</u></span> 代码如下:</div>
<div id="code92641">
<br>
$line    = fgets($this-&gt;connection, 512);</div>
<p>
 </p>
<p>
;时,发生超时错误。</p>
<p>
注释掉该函数的执行,直接发送邮件,则返回错误ehlo command failed。</p>
<p>
但打印出链接数据时,确实连上了。</p>
<p>
之前用别的程序发送邮件也是可以正常发送的,于是重新发送函数,改用phpmailer发送邮件。</p>
<p>
 </p>
<div>
<span><u>复制代码</u></span> 代码如下:</div>
<div id="code84355">
<br>
function smtp_mail($name, $email, $subject, $content, $type = 1, $notification=false) {<br>
     /* 如果邮件编码不是EC_CHARSET,创建字符集转换对象,转换编码 */<br>
    if ($GLOBALS['_CFG']['mail_charset'] != EC_CHARSET)<br>
    {<br>
        $name      = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $name);<br>
        $subject   = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $subject);<br>
        $content   = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $content);<br>
        $shop_name = ecs_iconv(EC_CHARSET, $GLOBALS['_CFG']['mail_charset'], $GLOBALS['_CFG']['shop_name']);<br>
    }<br>
    $charset   = $GLOBALS['_CFG']['mail_charset'];<br>
    include_once ROOT_PATH . 'includes/phpmailer/class.phpmailer.php';<br>
    $mail = new PHPMailer();<br>
    $mail-&gt;From = $GLOBALS['_CFG']['smtp_user'];<br>
    $mail-&gt;FromName = '云南***播有限公司';<br>
    if ($GLOBALS['_CFG']['mail_service'] == 0) {<br>
        $mail-&gt;isMail();<br>
    } else {<br>
        $mail-&gt;IsSMTP();<br>
        $mail-&gt;Host = $GLOBALS['_CFG']['smtp_host'];<br>
        $mail-&gt;Port = $GLOBALS['_CFG']['smtp_port'];<br>
        $mail-&gt;SMTPAuth = !empty($GLOBALS['_CFG']['smtp_pass']);<br>
        $mail-&gt;Username = $GLOBALS['_CFG']['smtp_user'];<br>
        $mail-&gt;Password = $GLOBALS['_CFG']['smtp_pass'];<br>
    }<br>
    $mail-&gt;Encoding = "base64";<br>
    //$mail-&gt;Priority     = $this-&gt;priority;<br>
    $mail-&gt;CharSet      = $charset;<br>
    $mail-&gt;IsHTML($type);<br>
    $mail-&gt;Subject      = $subject;<br>
    $mail-&gt;Body         = $content;<br>
    $mail-&gt;Timeout      = 30;<br>
    $mail-&gt;SMTPDebug    = false;<br>
    $mail-&gt;ClearAddresses();<br>
    $mail-&gt;AddAddress($email, $name);<br>
    $mail-&gt;ConfirmReadingTo = $notification;<br>
    $res = $mail-&gt;Send(); <br>
    if (!$res)<br>
    {<br>
        $GLOBALS['err']-&gt;add($mail-&gt;ErrorInfo);<br>
        $GLOBALS['err']-&gt;add($GLOBALS['_LANG']['sendemail_false']);<br>
        return false;<br>
    }<br>
    return true;<br>
}</div>
<p>
 </p>
<p>
以上就是本文的全部内容了,希望小伙伴们能够喜欢。</p>
頁: [1]
查看完整版本: ecshop实现smtp发送邮件