Sending email get MIME error

edited November 2012 in News & Announcements
Hello,

I have a controller where I send emails to the user.

In Outlook, I recieve one email fine the second gives me problems:

I get funny characters in the subject: =?utf-8?Q?Coffee_Order_-_Highland_Coffee_Roastery_-_Your_coffee_has_been

and an error in the body:
?=
=?utf-8?Q?_posted.?=
Reply-To: "noreply@highlandcoffeeroastery.co.za"
X-Sender: noreply@highlandcoffeeroastery.co.za
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5093827ced240@highlandcoffeeroastery.co.za>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5093827ced263"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_5093827ced263
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

I'm sending both emails from the same function in the controller.
I've tried a few things nothing helps:

1. I rewrote the subject line.

2. I saved the view file of the email that goes well as the email that doesn't. So both emails send exactly the same code.

What could cause this?

My controller code: (The view that gives problems is the one with the subject: 'Your coffee has been posted.' Marked it with /***********PROBLEM HERE *****************/
function updateOrder() { $this->load->helper('form'); $this->load->model('tank_auth/users'); $this->load->library('form_validation'); if(empty($_POST)) $orderId = $this->uri->segment(3); else $orderId = $this->input->post('orderId'); $row = $this->admin_model->getOrder($orderId); $userId = $row->user_id; $data['userId'] = $userId; $data['cancelled'] = $row->cancelled; $data['date'] = $row->order_date; $invoiceNo = $row->invoice_no; $paid = $row->paid; $trackingNo = $row->tracking_no; $customerName = $this->users->getUserName($userId); $data['firstName'] = $customerName->first_name; $data['lastName'] = $customerName->last_name; $this->load->model('order/orderonline_model'); $data['company'] = $this->orderonline_model->getOrderCompany($userId, $orderId); $data['msg'] = ''; if(empty($_POST)): $data['orderId'] = $orderId; $data['invoiceNo'] = $invoiceNo; $data['paid'] = $paid; $data['trackingNo1'] = substr($trackingNo, 0, 2); $data['trackingNo2'] = substr($trackingNo, 2, 9); $data['trackingNo3'] = substr($trackingNo, 10, 2); else: //form posted $this->load->library('form_validation'); $data['cancelled'] = false; $data['orderId'] = $this->input->post('orderId'); $data['date'] = $this->input->post('date'); $data['userId'] = $this->input->post('userId'); $data['invoiceNo'] = $this->security->xss_clean($this->input->post('invoiceNo')); $data['paid'] = $this->input->post('paid'); $data['trackingNo1'] = $this->security->xss_clean($this->input->post('trackingNo1')); $data['trackingNo2'] = $this->security->xss_clean($this->input->post('trackingNo2')); $data['trackingNo3'] = $this->security->xss_clean($this->input->post('trackingNo3')); $postTrackingNo = strtoupper($data['trackingNo1']) . $data['trackingNo2'] . strtoupper($data['trackingNo3']); if($data['invoiceNo'] != $invoiceNo): $this->load->model('admin_model'); $this->admin_model->updateOrder($data['orderId'], 'invoice_no', $data['invoiceNo']); $data['msg'] = '<p>The invoice number was updated succesuflly.</p>'; endif;//Update invoice no if($data['paid'] == 'Yes' && $paid == 'No'): $row = $this->admin_model->getOrder($orderId); $view = 'admin/paymentconfirm_view'; $subject = 'Payment recieved'; $orderDets = array('orderId'=>$data['orderId'], 'invoiceNo'=>$data['invoiceNo'], 'trackingNo'=>$trackingNo, 'date'=>$data['date']); $result = $this->sendemail($userId, $orderDets, $view, $subject); if($result): $this->admin_model->updateOrder($data['orderId'], 'paid', 'Yes'); $data['msg'] .= '<p>The order has been updated as Paid and an email has been sent to the customer.</p>'; else: $data['msg'] .= '<p><span class="error">Error trying to update Paid: There was a problem seding email to customer: ' . $this->email->print_debugger() . ', Please <a href="contact">contact the site administrator.</a></span></p>'; endif; endif;//End paid if($postTrackingNo != $trackingNo && $trackingNo == ''): $this->form_validation->set_rules('trackingNo1', 'first part of Tracking No', 'required|alpha|min_length[2]|max_length[2]'); $this->form_validation->set_rules('trackingNo2', 'second part of Tracking No', 'required|numeric|min_length[9]|max_length[9]'); $this->form_validation->set_rules('trackingNo3', 'third part of Tracking No', 'required|alpha|min_length[2]|max_length[2]'); /***********PROBLEM HERE *****************/ if($this -> form_validation -> run() === TRUE): $view = 'admin/trackingno_view'; $subject = 'Your coffee has been posted.'; $orderDets = array('orderId'=>$data['orderId'], 'invoiceNo'=>$data['invoiceNo'], 'trackingNo'=>$postTrackingNo, 'date'=>$data['date']); $result = $this->sendemail($userId, $orderDets, $view, $subject); if($result): $this->admin_model->updateOrder($data['orderId'], 'tracking_no', $postTrackingNo); $data['msg'] .= '<p>The tracking number has been updated and an email has been sent to the customer.</p>'; else: $data['msg'] .= '<p><span class="error">Error trying to update the tracking number: There was a problem seding email to customer: ' . $this->email->print_debugger() . ', Please <a href="contact">contact the site administrator.</a></span></p>'; endif; endif;//End validation success endif;//End tracking number endif; $this->load->view('admin/manageorder_view', $data); }

Comments

Sign In or Register to comment.