mail is not sending using codeigniter php -


i want send email users when registered. have used email api send mail user.

my controller code:

$this->load->model('user_model'); $verify = $this->user_model->insertuser(); $this->verifymail($username,$verify); $user_data = array(     'email' => $email,     'username' => $username,     'logged_in' => true  ); $this->sendmail(); $this->session->set_userdata($user_data); redirect('user/about_me'); 

my mail code :

function sendmail() {     //***************email api ***********************************************************     $headers = "mime-version: 1.0\r\n";     $headers .= "content-type: text/html; charset=iso-8859-1\r\n";     $headers .= "from: hp <crm@example.com>\r\n";     $headers .= "cc: hp@example.com\r\n";         $mailbox= "<pre style=\"font-family:verdana, geneva, sans-serif;\">                 test                 </pre>";      $subject = "ttest \r\n" ;      $email_to = "hp@example.com" ;      if($email_to != '') {         mail($email_to, $subject, $mailbox, $headers);     }        } 

looks need set user data before send email , include user data inside sendmail.

here changes:

$this->session->set_userdata($user_data); $this->sendmail();  $email_to = $this->session->userdata("email"); 

here full example:

$this->load->model('user_model'); $verify = $this->user_model->insertuser(); $this->verifymail($username,$verify); $user_data = array(     'email' => $email,     'username' => $username,     'logged_in' => true  ); $this->session->set_userdata($user_data); $this->sendmail(); redirect('user/about_me');   function sendmail() {     //***************email api ***********************************************************     $headers = "mime-version: 1.0\r\n";     $headers .= "content-type: text/html; charset=iso-8859-1\r\n";     $headers .= "from: hp <crm@example.com>\r\n";     $headers .= "cc: hp@example.com\r\n";         $mailbox= "<pre style=\"font-family:verdana, geneva, sans-serif;\">                 test                 </pre>";      $subject = "ttest \r\n" ;      $email_to = $this->session->userdata("email");      if($email_to != '') {         mail($email_to, $subject, $mailbox, $headers);     }        } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -