Page 1 of 1

Problem sending mail

Posted: Mon Nov 09, 2015 10:25 pm
by bubbsnurr
Hi everybody.
-------------------------
I am using opencart 2.0.3.1

I get the following when my shipping module tries to send a mail to customers. I got absolutely no support from the company sellign this module, so I try to solve it my self.

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

<b>Warning</b>: Invalid argument supplied for foreach() in <b>/storage/content/15/162215/gshoppen.se/public_html/system/library/mail.php</b> on line <b>22</b>{"status":true,"message":"S\u00e4ndingen med kolli id #73400014568091967 bokades!","orderstatus":"Skickad","consignment_id":"1446815878306d3ece0d8","consignment_no":"73400014568091967","date":"2015-11-06","success":"S\u00e4ndingen med kolli id #73400014568091967 bokades!"}
--------------------------------

The code in the module looks like this:

// Create comment and send to customer (and adding a post to the order history log)
private function addOrderHistory($order_info, $consignment_no, $status_id, $booked, $message) {

if ($this->config->get('memnonapport_notify_customer') && $order_info['email'] && $booked) {

// Load Language
$this->load->language('shipping/memnonapport');

$log = new Log('memnon_apport.log');
$subject = str_replace('{consignment_no}', $consignment_no, $this->language->get('text_comment_subject'));
$comments = $this->config->get('memnonapport_comment');

if (isset($comments[$order_info['language_id']])) {

// If a copy should be sent to the store owner
if ($this->config->get('memnonapport_secret_copy') && $this->config->get('config_email')) {
$recipient = $order_info['email'] . ',' . $this->config->get('config_email');
}
else {
$recipient = $order_info['email'];
}

$comment = $comments[$order_info['language_id']];
$comment = str_replace('{consignment_no}', $consignment_no, $comment);
$comment = str_replace('{order_id}', $order_info['order_id'], $comment);
$comment = str_replace('{firstname}', $order_info['firstname'], $comment);
$comment = str_replace('{lastname}', $order_info['lastname'], $comment);
$comment = str_replace('{store_name}', $order_info['store_name'], $comment);
$comment = str_replace('{store_owner}', $this->config->get('config_owner'), $comment);
$comment = str_replace('{store_phone}', $this->config->get('config_telephone'), $comment);
$comment = str_replace('{store_email}', $this->config->get('config_email'), $comment);
$comment = str_replace('{store_address}', $this->config->get('config_address'), $comment);

$mail = new Mail($this->config->get('config_mail'));
$mail->setTo($recipient);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($comment, ENT_QUOTES, 'UTF-8'));
$mail->send();
--------------------------

Grateful for any tips that could solve this problem!

Thanx / Tomas

Re: Problem sending mail

Posted: Mon Nov 09, 2015 10:26 pm
by bubbsnurr
The email is sent to all addresses, but its generating a pop up with the error message.