At the Back office, Sales -> Mail function, we can only send the mails with same Subject, and also same message.
So, I want to use some filed such as customer's name, customer's email..
And when I write the mail Subject, I can use {NAME} instead of customer's name.., so the message..
So, let show how I get start.
Modify: admin\controller\sale\contact.php
find
Code: Select all
$emails[$result['customer_id']] = $result['email'];
Code: Select all
$emails[] = array(
'name' => $result['name'],
'email' => $result['email']
);
Code: Select all
$emails[] = $customer_info['email'];
Code: Select all
$emails[] = array(
'name' => $customer_info['name'],
'email' => $customer_info['email']
);
Code: Select all
if ($emails) {
$message = '<html dir="ltr" lang="en">' . "\n";
$message .= '<head>' . "\n";
$message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
$message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
$message .= '</head>' . "\n";
$message .= '<body>' . html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
$message .= '</html>' . "\n";
Code: Select all
if ($emails) {
$MailTitle = $this->request->post['subject'];
$message = '<html dir="ltr" lang="en">' . "\n";
$message .= '<head>' . "\n";
$message .= '<title>{TITLE}</title>' . "\n";
$message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
$message .= '</head>' . "\n";
$message .= '<body>'.html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8').'</body>' . "\n";
$message .= '</html>' . "\n";
and last we need to change the sendmail function;
so find:
Code: Select all
foreach ($emails as $email) {
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$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($email);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject($this->request->post['subject']);
foreach ($attachments as $attachment) {
$mail->addAttachment($attachment['path'], $attachment['filename']);
}
$mail->setHtml($message);
$mail->send();
}
Code: Select all
foreach ($emails as $email) {
$TmpTitle = $MailTitle;
$TmpBody = $message;
$TmpTitle = str_replace("{NAME}",$email["name"],$TmpTitle);
$TmpTitle = str_replace("{EMAIL}",$email["email"],$TmpTitle);
$TmpBody = str_replace("{NAME}",$email["name"],$TmpBody);
$TmpBody = str_replace("{EMAIL}",$email["email"],$TmpBody);
$TmpBody = str_replace("{TITLE}",$TmpTitle,$TmpBody);
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$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($email['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject($TmpTitle);
foreach ($attachments as $attachment) {
$mail->addAttachment($attachment['path'], $attachment['filename']);
}
$mail->setHtml($TmpBody);
$mail->send();
}
}
And I uploaded the new contact.php file.
I tested, It work fine:)
Good luck.
Ady.