|  | 
 
 
 楼主|
发表于 2017-11-29 16:13:00
|
显示全部楼层 
| $send_email = $this->input->post('send_email');
 if (!$send_email) {
 dexit('邮箱不能为空');
 }
 if (!preg_match('/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/', $send_email)) {
 dexit('邮箱格式有误');
 }
 
 $this->load->library('email'); //加载CI的email类\
 //设置发送内容
 $this->email->from('18571499331@163.com', 'admin');//发送方
 $this->email->to($send_email);//接收方
 //$this->email->to('1025186947@qq.com');//接收方
 $this->email->subject('邮箱验证码');//标题
 //unset($_SESSION['email_code']);
 $email_code = rand(100000, 999999);
 $html = '<html><head></head><body>本次验证码是' . $email_code . '请在2分钟内输入</body></html>';
 //$this->email->message('本次验证码是' . $email_code . '请在2分钟内输入');//主题(内容样式可自行编辑)
 $this->email->message($html);//主题(内容样式可自行编辑)
 //$this->email->send();
 //echo $this->email->print_debugger();
 if ($this->email->send()) {//成功返回true
 //echo '成功';
 //$_SESSION['email_code'] = $email_code;
 dexit('发送成功', false, $email_code);
 } else {
 //echo '失败';
 dexit('获取失败,请重新获取');
 }
 我现在的代码是这样的,有时候能发送成功,有时候不能,不知道为啥,如果直接不用变量发送基本没问题,但是从前台获取到的邮箱值有时候会发送失败,不知道为啥
 | 
 |