在codeigniter电子邮件中添加额外的头信息 [英] Add extra header information in codeigniter email
问题描述
我想从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;
}
}
然后,您可以使用这样的新电子邮件类:
You'd then be able to set headers using your new email class like this:
$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屋!