Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html email does not send in codeigniter

This is my code to send HTML email but its not working properly. Just raw html code is shown in the email.

        $emailID = $this->input->post('email');
        $name = $this->input->post('name');

        $this->load->library('email');

        $config['protocol'] = 'smtp';
        $config['mailtype'] = 'html';
        $config['crlf'] = "\r\n";
        $config['wordwrap'] = TRUE;
        $config['newline'] = "\r\n";
        $config['validate'] = FALSE;

        $this->email->set_newline("\r\n");
        $this->email->from($emailID,$name);
        $this->email->to('[email protected]');
        $this->email->subject('Email Testing');
        $this->email->message('from clientside mail'); 
        $this->email->send();  

        $message = $this->load->view('emailfile/file','',TRUE);             
        $this->load->library('email', $config);
        $this->email->from($emailID,$name);
        $this->email->to($emailID,$name);
        $this->email->subject('Email Testing');
        $this->email->message($message);   
        $this->email->send();
        //echo $this->email->print_debugger();
like image 876
Vishvajit Mahida Avatar asked May 18 '26 04:05

Vishvajit Mahida


1 Answers

Add $this->email->initialize($config);:

$this->load->library('email');  
$config['protocol'] = 'smtp';
$config['mailtype'] = 'html';
$config['crlf'] = "\r\n";
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$config['validate'] = FALSE;
$this->email->initialize($config);
like image 73
diiN__________ Avatar answered May 20 '26 20:05

diiN__________



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!