Jump to content

Help with sending emails from back office - Error reporting


Recommended Posts

Hi All,

I am guessing that this is the suspect code:

/* Add a new message for the current order and send an e-mail to the customer if needed */
       elseif (isset($_POST['submitMessage']))
       {
           $_GET['view'.$this->table] = true;
            if ($this->tabAccess['edit'] === '1')
           {
               if (!($id_order = intval(Tools::getValue('id_order'))) OR !($id_customer = intval(Tools::getValue('id_customer'))))
                   $this->_errors[] = Tools::displayError('an error occurred before sending message');
               elseif (!Tools::getValue('message'))
                   $this->_errors[] = Tools::displayError('message cannot be blank');
               else
               {
                   /* Get message rules and and check fields validity */
                   $rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
                   foreach ($rules['required'] AS $field)
                       if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
                           if (!Tools::getValue('id_'.$this->table) OR $field != 'passwd')
                               $this->_errors[] = Tools::displayError('field').' '.$field.' '.Tools::displayError('is required');
                   foreach ($rules['size'] AS $field => $maxLength)
                       if (Tools::getValue($field) AND Tools::strlen(Tools::getValue($field)) > $maxLength)
                           $this->_errors[] = Tools::displayError('field').' '.$field.' '.Tools::displayError('is too long').' ('.$maxLength.' '.Tools::displayError('chars max').')';
                   foreach ($rules['validate'] AS $field => $function)
                       if (Tools::getValue($field))
                           if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8')))
                               $this->_errors[] = Tools::displayError('field').' '.$field.' '.Tools::displayError('is invalid');
                   if (!sizeof($this->_errors))
                   {
                       $message = new Message();
                       $message->id_employee = intval($cookie->id_employee);
                       $message->message = htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8');
                       $message->id_order = $id_order;
                       $message->private = Tools::getValue('visibility');
                       if (!$message->add())
                           $this->_errors[] = Tools::displayError('an error occurred while sending message');
                       elseif ($message->private)
                           Tools::redirectAdmin($currentIndex.'&id;_order='.$id_order.'&vieworder&conf;=11'.'&token;='.$this->token);
                       elseif (Validate::isLoadedObject($customer = new Customer($id_customer)))
                       {
                           $order = new Order(intval($message->id_order));
                           if (Validate::isLoadedObject($order))
                           {
                               $title = html_entity_decode($this->l('New message regarding your order').' '.$message->id_order, ENT_NOQUOTES, 'UTF-8');
                               $varsTpl = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => $message->id_order, '{message}' => (Configuration::get('PS_MAIL_TYPE') == 2 ? $message->message : nl2br2($message->message)));
                               if (Mail::Send(intval($order->id_lang), 'order_merchant_comment', $title, $varsTpl, $customer->email, $customer->firstname.' '.$customer->lastname))
                                   Tools::redirectAdmin($currentIndex.'&id;_order='.$id_order.'&vieworder&conf;=11'.'&token;='.$this->token);
                           }
                       }
                       $this->_errors[] = Tools::displayError('an error occurred while sending e-mail to the customer');
                   }
               }
           }
           else
               $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
       }



The error I am getting is $this->_errors[] = Tools::displayError('an error occurred while sending e-mail to the customer');

Is there a way to check for errors here like in adding to database in php/mysql?

Cheers

Link to comment
Share on other sites

I look at the customers account, and on the left hand side near the bottom is the box for sending a customer a message. I am trying to send the default one (about out of stock) as a test. Once I click send, the page refreshes, and at the top the error 'an error occurred while sending e-mail to the customer’ appears an the email is not received.

Thanks for your help

Link to comment
Share on other sites

  • 1 year later...

I have this problem also, i can send testmails through php mail and i can receive the testmail also, but when i´m trying to send through the BO ordermessage field I receive the error "an error occurred while sending e-mail to the customer" and no email is being sent

I run on PS 1,3,7 does any1 know a solution for this?

Link to comment
Share on other sites

  • 1 year later...

I have this problem also, i can send testmails through php mail and i can receive the testmail also, but when i´m trying to send through the BO ordermessage field I receive the error "an error occurred while sending e-mail to the customer" and no email is being sent

 

I run on PS 1,3,7 does any1 know a solution for this?

 

did you fix it?

Link to comment
Share on other sites

×
×
  • Create New...