Opencart 2.0 email doesn’t send

To fix the email issue in opencart 2.0 do the following changes on in necessary model file,

$mail = new Mail();
$mail->protocol = $this->config->get(‘config_mail_protocol’);
$mail->parameter = $this->config->get(‘config_mail_parameter’);
//$mail->smtp_hostname = $this->config->get(‘config_mail_smtp_host’);

The above line should be changed as below

$mail->smtp_hostname = $this->config->get(‘config_mail_smtp_hostname’);
$mail->smtp_username = $this->config->get(‘config_mail_smtp_username’);
$mail->smtp_password = html_entity_decode($this->config->get(‘config_mail_smtp_password’), ENT_QUOTES, ‘UTF-8’);
$mail->smtp_port = $this->config->get(‘config_mail_smtp_port’);
$mail->smtp_timeout = $this->config->get(‘config_mail_smtp_timeout’);

$mail->setTo($this->request->post[’email’]);
$mail->setFrom($this->config->get(‘config_email’));
$mail->setSender(html_entity_decode($this->config->get(‘config_name’), ENT_QUOTES, ‘UTF-8’));
$mail->setSubject($subject);
$mail->setText($message);
$mail->send();