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



在通过循环提交电子邮件时,我有问题。我在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>

我还使用Postmark监视我的电子邮件,当我单击电子邮件时,HTML格式获取正确的名称,但是当我单击纯文本格式时,它具有不正确的名称。

示例:html:说:"嗨,杰克谢谢你的事"。纯文本:说"嗨,安德森谢谢你的事"。

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

尝试使用:

  $this->email->set_alt_message('This is the alternative message');

相关内容

  • 没有找到相关文章

最新更新