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?
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);
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.
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.
You can try this line of code which will set the mail type to be for HTML
:
$this->email->set_mailtype("html");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With