【发布时间】:2017-01-18 16:09:45
【问题描述】:
我在 Code Igniter 中使用 REST API,并尝试从我的 REST 控制器发送电子邮件。这是我尝试过的:
public function registration_post(){
$jsonArray = json_decode(file_get_contents('php://input'),true);
$user_name = $jsonArray['user_name'];
$email = $jsonArray['email'];
$password = $jsonArray['password'];
$result = $this->reg_model->insert_api($user_name,$email,$password);
if ($result){
$this->load->library('email');
$from_email = "abc@gmail.com";
$this->email->from($from_email, 'Name');
$this->email->to($email);
$this->email->subject('email subject');
$message = 'email body';
$this->email->message($message);
$this->email->send();
$data = $this->response($this->reg_model->get($user_name));
}
}
这是一个 POST 请求 API,我通过 POST 调用成功地将用户数据插入数据库,然后发送电子邮件。但是,电子邮件没有发送。
insert_api() 函数将数据插入数据库,我也从 get() 函数得到响应。
【问题讨论】:
-
Setting Email Preferences 设置是否正确。
标签: php rest codeigniter api email