使用sendgrid和codeigniter向多个收件人发送邮件

问题描述:

我最近注册了SendGrid,看看他们与CodeIgniter的集成。

I recently signed up for SendGrid and took a look at their integration into CodeIgniter.

他们建议您通过以下方式发送邮件:

They recommend doing the following to send mail out:

 $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('your@example.com', 'Your Name');
    $this->email->to('someone@example.com');
    $this->email->cc('another@another-example.com');
    $this->email->bcc('them@their-example.com');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');
    $this->email->send();

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

这似乎是一个很好的解决方案,发送电子邮件给单个人,但如果我有一封电子邮件我想送给一大群人?是否可以发送到或bcc作为数组?

This seems like a nice solution for sending out emails to single individuals but what if I have an email that I want to send to a whole bunch of people? Is it possible to send either the "to" or the "bcc" in as an array?

有使用SendGrid和CI的首选集成方法吗?

Is there a different integration method preferred for using SendGrid with CI?

谢谢!

。您可以传递电子邮件地址数组或逗号分隔的电子邮件地址字符串。

You can use it in the normal way. You can pass an array of email addresses or a comma separated string of email addresses.

$list = array('one@example.com', 'two@example.com', 'three@example.com');
// or
//$list = 'one@example.com, two@example.com, three@example.com';

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