Kanted
Kanted

Reputation: 169

Opencart contact form: Need sender email id in subject or body of email sent

Would like to have sender email id in subject of the email or the body of the email which is generated via opencart's default contact page. I have tried editing the catalog/controller/information/contact.php file

$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->setSender($this->request->post['name']);

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));

$mail->send();

to

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name'], $this->request->post['email']), ENT_QUOTES, 'UTF-8'));`   

the above did not help. Let me know what to try or correct.

Upvotes: 3

Views: 690

Answers (1)

Mehravish Temkar
Mehravish Temkar

Reputation: 4365

Try this for subject

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'),$this->request->post['name']).', Email '.$this->request->post['email'], ENT_QUOTES, 'UTF-8')); 

Or this for subject

$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'),'').'From '.$this->request->post['name'].', Email '.$this->request->post['email'], ENT_QUOTES, 'UTF-8'));

or this for body

$mail->setHtml(html_entity_decode('Enquiry: '.$this->request->post['enquiry'].'<br/> From: '.$this->request->post['name'].'<br/> Email: '.$this->request->post['email'], ENT_QUOTES, 'UTF-8'));

Upvotes: 1

Related Questions