Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send html mail using codeigniter

Tags:

Error in mail content using SMTP in codeigniter Actually, my mail is sent with HTML tags and it is showing the HTML tags which is not correct.

$config = Array( 'protocol' => 'smtp',         'smtp_host' => 'ssl://smtp.googlemail.com',         'smtp_port' => 465,         'smtp_user' => '[email protected]',         'smtp_pass' => '',         'mailtype'  => 'html',          'charset' => 'utf-8',         'wordwrap' => TRUE      );     $this->load->library('email', $config);     $this->email->set_newline("\r\n");     $email_body ="<div>hello world</div>";     $this->email->from('[email protected]', 'ddd');      $list = array('[email protected]');     $this->email->to($list);     $this->email->subject('Testing Email');     $this->email->message($email_body);      $this->email->send();     echo $this->email->print_debugger(); 

If am sending mail without using SMTP it works fine. What is my mistake?

like image 852
user1182623 Avatar asked Feb 01 '12 12:02

user1182623


People also ask

How to send HTML email in gmail in CodeIgniter?

codeigniter Sending Email Send An HTML EmailSet your config file as html: $config['mailtype'] = 'html'; If you want to pass data (like a username for example) to the html email, put them in an array: $data = array('name' => $name, 'email' => $email, 'phone' => $phone, 'date' => $date);

How to send mail in PHP CodeIgniter?

Sending an EmailThe subject() and message() function is used to set the subject and message of the email. $this->email->from('[email protected]', 'Your Name'); $this->email->to('[email protected]'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.

What is SMTP in CodeIgniter?

Send email via SMTP server in CodeIgniter At first include the CodeIgniter email library. Now specify the SMTP host ( smtp_host ), port ( smtp_port ), email ( smtp_user ), and password ( smtp_pass ) in SMTP configuration ( $config ) as per your SMTP server.


Video Answer


1 Answers

You can try this line of code which will set the mail type to be for HTML:

 $this->email->set_mailtype("html"); 
like image 156
Gabriel Avatar answered Oct 31 '22 18:10

Gabriel