加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 使用sendgrid和codeigniter将邮件发送给多个收件人

发布时间:2020-12-13 13:50:07 所属栏目:PHP教程 来源:网络整理
导读:我最近注册了SendGrid并看了他们与CodeIgniter的集成. 他们建议您执行以下操作以发送邮件: $this-email-initialize(array( 'protocol' = 'smtp','smtp_host' = 'smtp.sendgrid.net','smtp_user' = 'sendgridusername','smtp_pass' = 'sendgridpassword','sm
我最近注册了SendGrid并看了他们与CodeIgniter的集成.

他们建议您执行以下操作以发送邮件:

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

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

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

对于将SendGrid与CI一起使用,是否存在不同的集成方法?

谢谢!

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

喜欢

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读