How to Send HTML email in opencart

How to Send HTML email in opencart – PHP Cluster

Hello friends, today I am going to talk about how to send html email in Opencart for store mail. Generally, we feel need of different email template for mail and we prefer to use html email template . So, Now I am discussing in detail about how to use html email in opencart store easily. Let us see below in detail.
Send html email in opencart
// put this above code for your html email

$mail->setHtml(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));

See example shown below :-

$mail = new Mail();
                $mail->protocol = $this->config->get('config_mail_protocol');
                $mail->parameter = $this->config->get('config_mail_parameter');
                $mail->hostname = $this->config->get('config_smtp_host');
                $mail->username = $this->config->get('config_smtp_username');
                $mail->password = $this->config->get('config_smtp_password');
                $mail->port = $this->config->get('config_smtp_port');
                $mail->timeout = $this->config->get('config_smtp_timeout');             
                //$mail->setTo($this->config->get('config_email'));
                //$mail->setFrom($this->request->post['email']);

                $mail->setTo('test1@test.com');
                $mail->setFrom('test@test.com');

                $mail->setSender($this->request->post['name']);
                $mail->setSubject(html_entity_decode('La reserva de tu alquiler ha sido correcta', ENT_QUOTES, 'UTF-8'));
                $mailText = '
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html>
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    </head>
                    <body>
                        <div class="confirmacion">
                            <h1>This is my html template for email</h1>
                            <p> I am using this content for sending it as html content in mail for opencart store..</p>
                        </div>
                    </body>
                </html>';



               $mail->setHtml($mailText);
               $mail->setText(html_entity_decode($mailText, ENT_QUOTES, 'UTF-8'));
                $mail->send();

In this above example, we have assign html code within a variable $mailText and we pass that variable in setHtml() function for sending mail with html content. That’s all.