Question

This is how I'm currently sending notifications to the (two) admin of the shop

$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');     

$mailText = html_entity_decode($mailText,ENT_QUOTES, 'UTF-8');
/* Email para el admins Alcudia */
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setTo($admin_alcudia);
$mail->setSubject(html_entity_decode('Se ha realizado una solicitud de reserva', ENT_QUOTES, 'UTF-8'));
$mail->setHtml($mailText);
$mail->send();
/* Email para el admin de palma */
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setTo($admin_palma);
$mail->setSubject(html_entity_decode('Se ha realizado una solicitud de reserva', ENT_QUOTES, 'UTF-8'));
$mail->setHtml($mailText);
$mail->send();

The thing is that they're saying that the second one is not reciving it...

Any idea how to improve this? is there any CC functionality?

I've been waiting all day but http://docs.opencart.com/ won't get back to life..

Was it helpful?

Solution

Try separating the sendTo() function with commas in a string:

$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');     

$mailText = html_entity_decode($mailText,ENT_QUOTES, 'UTF-8');

$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setTo($admin_alcudia.','.$admin_palma);
$mail->setSubject(html_entity_decode('Se ha realizado una solicitud de reserva', ENT_QUOTES, 'UTF-8'));
$mail->setHtml($mailText);

$mail->send();

This should eliminate the need to have duplicate code.

OTHER TIPS

In OpenCart 2.x you need to pass in an array to the setTo() method.

$mail->setTo(array(0 => 'name@domain.com', 1 => 'name2@domain.com'));

The other option is to not have to modify any code and to change it in the settings,

If you go to system and then into settings and then click edit on your store it will open up the settings for your store...

You then need to go across to the mail tab ans then scroll down to the "Additional Alert E-Mails" text box and then simply add the additional email address

No change in coding necessary...

Hope this helps,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top