@@ -750,14 +750,13 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
750750 }
751751 }
752752
753+ $ sentAs = '' ;
753754 // so what do we actually send?
754755 switch ($ cached [$ messageid ]['sendformat ' ]) {
755756 case 'PDF ' :
756757 // send a PDF file to users who want html and text to everyone else
757758 if ($ htmlpref ) {
758- if (!$ isTestMail ) {
759- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set aspdf = aspdf + 1 where id = $ messageid " );
760- }
759+ $ sentAs = 'aspdf ' ;
761760 $ pdffile = createPdf ($ textmessage );
762761 if (is_file ($ pdffile ) && filesize ($ pdffile )) {
763762 $ fp = fopen ($ pdffile , 'r ' );
@@ -785,9 +784,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
785784 return 0 ;
786785 }
787786 } else {
788- if (!$ isTestMail ) {
789- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set astext = astext + 1 where id = $ messageid " );
790- }
787+ $ sentAs = 'astext ' ;
791788 $ mail ->add_text ($ textmessage );
792789 if (!addAttachments ($ messageid , $ mail , 'text ' ,$ hash )) {
793790 return 0 ;
@@ -797,9 +794,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
797794 case 'text and PDF ' :
798795 // send a PDF file to users who want html and text to everyone else
799796 if ($ htmlpref ) {
800- if (!$ isTestMail ) {
801- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set astextandpdf = astextandpdf + 1 where id = $ messageid " );
802- }
797+ $ sentAs = 'astextandpdf ' ;
803798 $ pdffile = createPdf ($ textmessage );
804799 if (is_file ($ pdffile ) && filesize ($ pdffile )) {
805800 $ fp = fopen ($ pdffile , 'r ' );
@@ -827,9 +822,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
827822 return 0 ;
828823 }
829824 } else {
830- if (!$ isTestMail ) {
831- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set astext = astext + 1 where id = $ messageid " );
832- }
825+ $ sentAs = 'astext ' ;
833826 $ mail ->add_text ($ textmessage );
834827 if (!addAttachments ($ messageid , $ mail , 'text ' ,$ hash )) {
835828 return 0 ;
@@ -838,9 +831,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
838831 break ;
839832 case 'text ' :
840833 // send as text
841- if (!$ isTestMail ) {
842- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set astext = astext + 1 where id = $ messageid " );
843- }
834+ $ sentAs = 'astext ' ;
844835 $ mail ->add_text ($ textmessage );
845836 if (!addAttachments ($ messageid , $ mail , 'text ' ,$ hash )) {
846837 return 0 ;
@@ -863,9 +854,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
863854 if (!$ handled_by_plugin ) {
864855 // send one big file to users who want html and text to everyone else
865856 if ($ htmlpref ) {
866- if (!$ isTestMail ) {
867- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set astextandhtml = astextandhtml + 1 where id = $ messageid " );
868- }
857+ $ sentAs = 'astextandhtml ' ;
869858 // dbg("Adding HTML ".$cached[$messageid]["templateid"]);
870859 if (WORDWRAP_HTML ) {
871860 //# wrap it: http://mantis.phplist.com/view.php?id=15528
@@ -879,9 +868,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
879868 return 0 ;
880869 }
881870 } else {
882- if (!$ isTestMail ) {
883- Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set astext = astext + 1 where id = $ messageid " );
884- }
871+ $ sentAs = 'astext ' ;
885872 $ mail ->add_text ($ textmessage );
886873// $mail->setText($textmessage);
887874// $mail->Encoding = TEXTEMAIL_ENCODING;
@@ -931,6 +918,11 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
931918 $ messageid , $ counters ['batch_count ' ], $ counters ['batch_total ' ], $ email , $ destinationemail ), 0 );
932919 } else {
933920 $ sendOK = true ;
921+
922+ if (!$ isTestMail && $ sentAs != '' ) {
923+ Sql_Query ("update {$ GLOBALS ['tables ' ]['message ' ]} set $ sentAs = $ sentAs + 1 where id = $ messageid " );
924+ }
925+
934926 foreach ($ GLOBALS ['plugins ' ] as $ pluginname => $ plugin ) {
935927 $ plugin ->processSendSuccess ($ messageid , $ userdata , $ isTestMail );
936928 }
0 commit comments