diff --git a/application/helpers/mailer_helper.php b/application/helpers/mailer_helper.php index d2e35cc2e..cfa993e79 100644 --- a/application/helpers/mailer_helper.php +++ b/application/helpers/mailer_helper.php @@ -45,6 +45,8 @@ function email_invoice($invoice_id, $invoice_template, $from, $to, $subject, $bo $bcc = parse_template($db_invoice, $bcc); $from = array(parse_template($db_invoice, $from[0]), parse_template($db_invoice, $from[1])); + $message = (empty($message) ? ' ' : $message); + return phpmail_send($from, $to, $subject, $message, $invoice, $cc, $bcc, $attachments); } @@ -66,6 +68,8 @@ function email_quote($quote_id, $quote_template, $from, $to, $subject, $body, $c $bcc = parse_template($db_quote, $bcc); $from = array(parse_template($db_quote, $from[0]), parse_template($db_quote, $from[1])); + $message = (empty($message) ? ' ' : $message); + return phpmail_send($from, $to, $subject, $message, $quote, $cc, $bcc, $attachments); } diff --git a/application/modules/mailer/controllers/mailer.php b/application/modules/mailer/controllers/mailer.php index 5c19e2a9e..e5d6a78e4 100755 --- a/application/modules/mailer/controllers/mailer.php +++ b/application/modules/mailer/controllers/mailer.php @@ -101,16 +101,20 @@ public function send_invoice($invoice_id) if (!$this->mailer_configured) return; $this->load->model('upload/mdl_uploads'); - $from = array($this->input->post('from_email'), - $this->input->post('from_name')); + $from = array( + $this->input->post('from_email'), + $this->input->post('from_name') + ); $pdf_template = $this->input->post('pdf_template'); $to = $this->input->post('to_email'); $subject = $this->input->post('subject'); + if (strlen($this->input->post('body')) != strlen(strip_tags($this->input->post('body')))) { $body = htmlspecialchars_decode($this->input->post('body')); } else { $body = htmlspecialchars_decode(nl2br($this->input->post('body'))); } + $cc = $this->input->post('cc'); $bcc = $this->input->post('bcc'); $attachment_files = $this->mdl_uploads->get_invoice_uploads($invoice_id); @@ -119,8 +123,7 @@ public function send_invoice($invoice_id) $this->mdl_invoices->mark_sent($invoice_id); $this->session->set_flashdata('alert_success', trans('email_successfully_sent')); - - redirect('dashboard'); + redirect('invoices/view/' . $invoice_id); } else { redirect('mailer/invoice/' . $invoice_id); } @@ -135,16 +138,20 @@ public function send_quote($quote_id) if (!$this->mailer_configured) return; $this->load->model('upload/mdl_uploads'); - $from = array($this->input->post('from_email'), - $this->input->post('from_name')); + $from = array( + $this->input->post('from_email'), + $this->input->post('from_name') + ); $pdf_template = $this->input->post('pdf_template'); $to = $this->input->post('to_email'); $subject = $this->input->post('subject'); + if (strlen($this->input->post('body')) != strlen(strip_tags($this->input->post('body')))) { $body = htmlspecialchars_decode($this->input->post('body')); } else { $body = htmlspecialchars_decode(nl2br($this->input->post('body'))); } + $cc = $this->input->post('cc'); $bcc = $this->input->post('bcc'); $attachment_files = $this->mdl_uploads->get_quote_uploads($quote_id); @@ -154,7 +161,7 @@ public function send_quote($quote_id) $this->session->set_flashdata('alert_success', trans('email_successfully_sent')); - redirect('dashboard'); + redirect('quotes/view/' . $quote_id); } else { redirect('mailer/quote/' . $quote_id); }