升级邮件
文档
变更点
- 只是一些小变化,如方法名称和库的加载。 
升级指南
- 在类中,将 - $this->load->library('email');改为- $email = service('email');。
- 从那时起,需要将以 - $this->email开头的每一行改为- $email。
- Email 类中的方法命名略有不同。除 - send()、- attach()、- printDebugger()和- clear()之外的所有方法都有一个- set前缀,后跟之前的方法名。- bcc()现在变为- setBcc(),等等。
- app/Config/Email.php 中的配置属性已更改。你应该查看 设置电子邮件首选项 以获取新的属性列表。 
代码示例
CodeIgniter 3.x 版本
<?php
$this->load->library('email');
$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();
CodeIgniter 4.x 版本
<?php
$email = service('email');
$email->setFrom('your@example.com', 'Your Name');
$email->setTo('someone@example.com');
$email->setCC('another@another-example.com');
$email->setBCC('them@their-example.com');
$email->setSubject('Email Test');
$email->setMessage('Testing the email class.');
$email->send();