提交电子邮件时,html和纯文本中的名称不同

时间:2017-02-22 21:22:47

标签: php codeigniter postmark

通过循环提交电子邮件时遇到问题。我用html和纯文本格式获得了不同的用户名。

这是我的控制器     功能报告(){

    $this->load->model('Searchmonitoring_db');
    $results = $this->Searchmonitoring_db->getLogs();

    if (!$results)
            return false;

    $this->load->library('email');
    $config['mailtype'] = 'html';
    $this->email->initialize($config);

    foreach ($results as $result) {

        $fname = $result['fname'];
        $username = $result['username'];
        $subject_keyword = $result['grpname'];

        if ($subject_keyword == "") {

            $findfields['clientid'] = $result['clientid'];
            $findfields['grouping'] = $result['grouping'];
            $keywords = $this->Searchmonitoring_db->getKeywords($findfields);

            if ($keywords['db']) {
                foreach ($keywords['db'] as $kw) {
                    if ($subject_keyword != "")
                            $subject_keyword .= ", ";
                    $subject_keyword .= $kw['query'];
                }
            }
        }

        $this->email->clear(TRUE);

        $managerEmail = $result['manager_email'];
        $manager = $result['manager'];
        $salespersonEmail = $result['salesperson_email'];
        $salesperson = $result['salesperson'];
        $clientEmail = $result['email'];

        if($managerEmail) {
            $this->email->from($managerEmail, $manager);
        } elseif($salespersonEmail) {
            $this->email->from($salespersonEmail, $salesperson);
        }

        $this->email->to($clientEmail);


        $arrfname = explode("/", $fname);
        $subject = "Your $subject_keyword monitoring report";
        $this->email->subject($subject);
        $message = $this->load->view('emailtemplate', $result, true);
        $this->email->message($message);
        $this->email->attach("../export/$username/" . end($arrfname) . ".zip");

        if ($this->email->send()) {
            $update['id'] = $result['logid'];
            $searchlog['result'] = 'Sent';
            $this->Searchmonitoring_db->updateLog($update, $searchlog);
        }
    }
}

这是我的电子邮件模板

<html>
<body>

<p>Hi <?php echo $firstname; ?></p>
<p>Thanks for your business!</p>
<p>
<?php
if($manager) {
    echo nl2br($manager_email_signature);
} elseif($salesperson) {
    echo nl2br($salesperson_email_signature);
} ?>
</p>
</body>
</html>

我还使用邮戳来监控我的电子邮件,当我点击电子邮件时,html格式会得到正确的名称,但是当我点击纯文本格式时,它的名称不正确。

例如: html:说“嗨杰克感谢您的业务”。 纯文本:“嗨,安德森感谢你的事业。”

我注意到纯文本获取了循环中第一封电子邮件的名称

0 个答案:

没有答案