From b84f522e706bdbb03201133aab667e4ff57a4c5d Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Tue, 28 Jul 2009 21:32:56 +0000 Subject: [PATCH] Bugs in sending documents as email. Seems to land in the spam filter due to bad text and scrambled name on attached documents --- CHANGELOG.txt | 10 +++++++--- reporting/includes/doctext.inc | 2 +- reporting/includes/doctext2.inc | 2 +- reporting/includes/header2.inc | 1 - reporting/includes/pdf_report.inc | 24 +++++++----------------- reporting/rep109.php | 1 + 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ea349432..896b53dd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,9 +19,13 @@ Legend: ! -> Note $ -> Affected files -27-Jul-2009 Joe Hunt -# Bugs in sending sales orders as email. -$ /reporting/includes/pdf_report.inc +28-Jul-2009 Joe Hunt +# Bugs in sending documents as email. Seems to land in the spam filter due to bad text and scrambled name on attached documents +$ /reporting/rep109.php + /reporting/includes/doctext.inc + /reporting/includes/doctext2.inc + /reporting/includes/header2.inc + /reporting/includes/pdf_report.inc 18-Jul-2009 Joe Hunt # When saving a Payment to a Customer in Bank Payments (normally payment to suppliers) it was saved with wrong sign in debtor_trans (very rare). diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index fdcd5484..5365d83d 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -78,7 +78,7 @@ if (isset($header2type)) } if (isset($emailtype)) { - $doc_Dear_Sirs = _("Dear Sirs"); + $doc_Dear_Sirs = _("Dear"); $doc_AttachedFile = _("Attached you will find "); $doc_Kindest_regards = _("Kindest regards"); $doc_Payment_Link = _("You can pay through"); diff --git a/reporting/includes/doctext2.inc b/reporting/includes/doctext2.inc index 1b70eee4..f022b504 100644 --- a/reporting/includes/doctext2.inc +++ b/reporting/includes/doctext2.inc @@ -77,7 +77,7 @@ if (isset($header2type)) } if (isset($emailtype)) { - $doc_Dear_Sirs = "Dear Sirs"; + $doc_Dear_Sirs = "Dear"; $doc_AttachedFile = "Attached you will find "; $doc_Kindest_regards = "Kindest regards"; $doc_Payment_Link = "You can pay through"; diff --git a/reporting/includes/header2.inc b/reporting/includes/header2.inc index d28726ff..1ec99386 100644 --- a/reporting/includes/header2.inc +++ b/reporting/includes/header2.inc @@ -281,7 +281,6 @@ if (($doctype == 10 || $doctype == 12) && $legal != "") { $this->TextWrap($ccol, $this->row, $right - $ccol, $legal, 'C'); - $this->NewLine(); } $this->Font(); $temp = $iline6 - $this->lineHeight - 2; diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 81fda39f..8d9bef0f 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -406,7 +406,10 @@ class FrontReport extends Cpdf } // do not use standard filenames or your sensitive company data // are world readable - $fname = $dir.'/'.uniqid('').'.pdf'; + if ($email == 1) + $fname = $dir.'/'.$this->filename; + else + $fname = $dir.'/'.uniqid('').'.pdf'; $this->Output($fname, 'F'); if ($email == 1) { @@ -421,8 +424,8 @@ class FrontReport extends Cpdf } require_once($path_to_root . "/reporting/includes/class.mail.inc"); $mail = new email($this->company['coy_name'], $this->company['email']); - $from = $this->company['coy_name'] . " <" . $this->company['email'] . ">"; - if (!isset($myrow['email']) || $myrow['email'] == '') $myrow['email'] = $myrow['contact_email']; + if (!isset($myrow['email']) || $myrow['email'] == '') + $myrow['email'] = $myrow['contact_email']; $to = $myrow['DebtorName'] . " <" . $myrow['email'] . ">"; $msg = $doc_Dear_Sirs . " " . $myrow['DebtorName'] . ",\n\n" . $doc_AttachedFile . " " . $subject . "\n\n"; @@ -445,25 +448,12 @@ class FrontReport extends Cpdf $mail->text($msg . $sender); $mail->attachment($fname); $ret = $mail->send(); - if (1 == 1) // just for fun and for debugging purposes!! - { - $from = str_replace("<", "(", $from); - $from = str_replace(">", ")", $from); - $to = str_replace("<", "(", $to); - $to = str_replace(">", ")", $to); - $msg2 = "
From: " . $from; - $msg2 .= "
To: " . $to; - $msg2 .= "
Subject: " . $subject; - $msg2 .= "
Msg: " . nl2br($msg); - $msg2 .= nl2br($sender) . "
"; - $msg2 .= "
Filepath: " . $fname . "
Filename: " . $this->filename . "
"; - } - if (!isset($myrow['reference'])) $myrow['reference'] = ''; if (!$ret) display_error(_("Sending document by email failed")); else display_notification($this->title . " " . $myrow['reference'] . " " . _("has been sent by email.")); + unlink($fname); } else { diff --git a/reporting/rep109.php b/reporting/rep109.php index 7c57da3f..00b06d2e 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -163,6 +163,7 @@ function print_sales_orders() $myrow['contact_email'] = $branch['email']; $myrow['DebtorName'] = $branch['br_name']; } + $myrow['reference'] = $i; $rep->End($email, $doc_Invoice_no . " " . $i, $myrow); } } -- 2.30.2