Bugs in sending documents as email. Seems to land in the spam filter due to bad text...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 28 Jul 2009 21:32:56 +0000 (21:32 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 28 Jul 2009 21:32:56 +0000 (21:32 +0000)
CHANGELOG.txt
reporting/includes/doctext.inc
reporting/includes/doctext2.inc
reporting/includes/header2.inc
reporting/includes/pdf_report.inc
reporting/rep109.php

index ea349432da236c1f23fc497630dc37e8a477e689..896b53dd0b43740e68bd9ea932b2159641a998c8 100644 (file)
@@ -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).
index fdcd548429d7f361650b202dd9b052015d821656..5365d83df9a102b2560b38f2c8cfe260b161f4b3 100644 (file)
@@ -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");
index 1b70eee4f4745a4ce9018048e60de96918a749b2..f022b504e2f6b173af5ae31d28605cf65d4b5a87 100644 (file)
@@ -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";
index d28726fff9f9bb989744e0df8e23011c029f4a28..1ec99386505d4ea4e08f7948a8d3f87098d51025 100644 (file)
                if (($doctype == 10 || $doctype == 12) && $legal != "") 
                {
                        $this->TextWrap($ccol, $this->row, $right - $ccol, $legal, 'C');
-                       $this->NewLine();
                }
                $this->Font();
                $temp = $iline6 - $this->lineHeight - 2;
index 81fda39f8ccdf2c744b1566254011e064a3ac19e..8d9bef0f86f1df55091a67660d9a99e06e75b27a 100644 (file)
@@ -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 = "<br>From: " . $from;
-                               $msg2 .= "<br>To: " . $to;
-                               $msg2 .= "<br>Subject: " . $subject;
-                               $msg2 .= "<br>Msg: " . nl2br($msg);
-                               $msg2 .= nl2br($sender) . "<br>";
-                               $msg2 .= "<br>Filepath: " . $fname . "<br>Filename: " . $this->filename . "<br>";
-                       }
-                       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
                        {
index 7c57da3f3f643afd30ff6d7ba4dda7ee85c3d351..00b06d2ef1f2c513bcf288a527f8e419f9fe6162 100644 (file)
@@ -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);
                }
        }