Sending mail to multiple recipients with sendgrid and codeigniter

我与影子孤独终老i 提交于 2019-11-28 09:05:07

问题


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();

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?

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

Thanks!


回答1:


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

Like

$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);


来源:https://stackoverflow.com/questions/13194618/sending-mail-to-multiple-recipients-with-sendgrid-and-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!