在codeigniter的电子邮件中添加额外的标题信息 [英] Add extra header information in codeigniter email

查看:222
本文介绍了在codeigniter的电子邮件中添加额外的标题信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发送一些关于从codeigniter库发送的电子邮件的额外信息。有任何方法来配置或添加这个?

I would like to send some extra information on the emails which is sent from codeigniter library. Is there any way to configure or add this?

我想对来自我的网站的所有外发邮件进行分类。我需要包括sendgrid类别标题进行跟踪。

I want to categorize all the outgoing mail from my site. I need to include sendgrid category header for tracking.

推荐答案

CodeIgniter电子邮件类不允许手动设置标题。但是,您可以通过扩展它并添加一个新的函数,允许您设置sendgrid头来更改这一点。

The CodeIgniter email class doesn't let you manually set headers. However you could change this by extending it and adding a new function that allows you to set the sendgrid headers.

请参阅CodeIgniter手册的扩展本机库部分:

http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html

以下是代码

See the "Extending Native Libraries" section of the CodeIgniter manual:
http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
Here's what the code in your new email class might look like.

class MY_Email extends CI_Email {

    public function __construct(array $config = array())
    {
        parent::__construct($config);
     }

    public function set_header($header, $value){
        $this->_headers[$header] = $value;
    }
}

这样的新电子邮件类:

$this->email->set_header($header, $value);

此页面将解释可传递给SendGrid的标头:
http://sendgrid.com/docs/API%20Reference/SMTP%20API/

This page will explain what headers can be passed to SendGrid: http://sendgrid.com/docs/API%20Reference/SMTP%20API/

这篇关于在codeigniter的电子邮件中添加额外的标题信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆