2012-11-02 171 views
3

我最近注册了SendGrid并查看了他们与CodeIgniter的集成。使用sendgrid和codeigniter向多个收件人发送邮件

他们建议做以下发送邮件了:

$this->email->initialize(array(
     'protocol' => 'smtp', 
     'smtp_host' => 'smtp.sendgrid.net', 
     'smtp_user' => 'sendgridusername', 
     'smtp_pass' => 'sendgridpassword', 
     'smtp_port' => 587, 
     'crlf' => "\r\n", 
     'newline' => "\r\n" 
    )); 

    $this->email->from('[email protected]', 'Your Name'); 
    $this->email->to('[email protected]'); 
    $this->email->cc('[email protected]'); 
    $this->email->bcc('[email protected]'); 
    $this->email->subject('Email Test'); 
    $this->email->message('Testing the email class.'); 
    $this->email->send(); 

    echo $this->email->print_debugger(); 

这似乎是向用户发送电子邮件,以单个人,而是什么一个很好的解决方案,如果我有,我要发送到一大堆的电子邮件的人?是否有可能以数组形式发送“to”或“bcc”?

是否有一种不同的集成方法首选使用SendGrid与CI?

谢谢!

回答

10

您可以正常使用它。您可以传递一组电子邮件地址或逗号分隔的一串电子邮件地址。

$list = array('[email protected]', '[email protected]', '[email protected]'); 
// or 
//$list = '[email protected], [email protected], [email protected]'; 

$this->email->to($list); 
// or 
//$this->email->cc($list); 
// or 
//$this->email->bcc($list); 
+1

也改为@ air4x答案,文档是你最好的朋友:) http://codeigniter.com/user_guide/libraries/email.html –

相关问题