我是 CI 的初学者。
这是我在welcome.php 中的代码
class Welcome extends CI_Controller {
public function index()
{
$this->load->helper('url');
$this->load->view('welcome_message');
}
public function emailSend()
{
$this->load->library('upload');
$this->load->library('email');
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->upload->initialize($config);
$this->email->from($this->input->post('from'), $this->input->post('name'));
$this->email->to('taryar.t1@gmail.com');
//$this->email->cc('another@another-example.com');
//$this->email->bcc('them@their-example.com');
$this->email->subject($this->input->post('subject'));
$this->email->message($this->input->post('body'));
if($this->upload->do_upload())
{
$attachdata=$this->upload->data();
$this->email->attach($attachdata['full_path']);
}
if($this->email->send())
{
echo 'Your email was sent, successfully.';
}
else
{
show_error($this->email->print_debugger());
}
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
此代码仅适用于文本,不适用于附件(图像)。错误是“无法使用 PHP mail() 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。”
我该如何解决这个错误?帮帮我。