I cannot understand why, if I try to use the CI email class, it does not send emails, and if I use the PHP mail () native class, it works.
It should be noted that sometimes I get "sent by e-mail", although it is not actually sent, and sometimes I get the error message "my server is not configured."
I tried to figure out how to configure it, but ... nothing ...
The following controller code:
if($this->form_validation->run()){ //Set Language $this->lang->load('site', $this->session->userdata('lang')); //Random key $user_valid_key = md5(uniqid()); //Prepare email $this->load->library('email', array('mailtype' => 'html')); $this->email->from($this->config->item('email_signup_from'), 'Wondermark.net'); $this->email->to($this->input->post('email')); $this->email->subject($this->lang->line('email_signup_subject')); //Format mail con %s per inserire i campi necessari $signup_msg = sprintf($this->lang->line('email_signup_message'), $this->input->post('fname'), base_url().'main/signup_confirm/'.$user_valid_key); $this->email->message((string)$signup_msg); if($this->email->send()){ //TODO: load view... echo "email sent"; }else{ $to = $this->input->post('email'); mail($to, 'test', 'Other sent option failed'); echo $this->input->post('email'); show_error($this->email->print_debugger()); } //TODO: Add to db }else{ // Form validation failed }
php email codeigniter
Mr.Web
source share