• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6556: using STARTPUBLISH removes headers, defeats sendmail

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension MailerContrib Normal New   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

There is a bug when using STARTPUBLISH/STOPPUBLISH that prevents emails from being sent (for me at least). The logic in MailerContrib.pm (using Rev. 19211) assembles the body, headers, and footers into a variable called $tmpl, then chops that down to only what is between the STARTPUBLISH/STOPPUBLISH tags - which wipes out the headers and footers. With no headers, sendmail fails with "No recipient addresses found in message header."

Here is a diff to MailerContrib.pm that moves the split code so that it only applies to the body, not the entire message.

--- /home/msi/vestrum/MailerContrib.pm  2010-08-19 12:04:40.968353000 -0500
+++ MailerContrib.pm    2010-08-19 12:05:40.340379901 -0500
@@ -435,33 +435,34 @@
 
     # Handle standard formatting.
     $body =~ s/%TEXT%/$text/g;
-    # Don't render the header, it is preformatted
-    $header = TWiki::Func::expandCommonVariables($header, $topic, $web);
-    my $tmpl = "$body\n$footer";
-    $tmpl = TWiki::Func::expandCommonVariables($tmpl, $topic, $web);
-    $tmpl = TWiki::Func::renderText($tmpl, "", $meta);
-    $tmpl = "$header$tmpl";
 
     # REFACTOR OPPORTUNITY: stop factor me into getTWikiRendering()
     # SMELL: this code is identical to PublishContrib!
 
     # New tags
-    my $newTmpl = '';
+    my $newBody = '';
     my $tagSeen = 0;
     my $publish = 1;
-    foreach my $s ( split( /(%STARTPUBLISH%|%STOPPUBLISH%)/, $tmpl )) {
+    foreach my $s ( split( /(%STARTPUBLISH%|%STOPPUBLISH%)/, $body )) {
         if( $s eq '%STARTPUBLISH%' ) {
             $publish = 1;
-            $newTmpl = '' unless( $tagSeen );
+            $newBody = '' unless( $tagSeen );
             $tagSeen = 1;
         } elsif( $s eq '%STOPPUBLISH%' ) {
             $publish = 0;
             $tagSeen = 1;
         } elsif( $publish ) {
-            $newTmpl .= $s;
+            $newBody .= $s;
         }
     }
-    $tmpl = $newTmpl;
+    $body = $newBody;
+
+    # Don't render the header, it is preformatted
+    $header = TWiki::Func::expandCommonVariables($header, $topic, $web);
+    my $tmpl = "$body\n$footer";
+    $tmpl = TWiki::Func::expandCommonVariables($tmpl, $topic, $web);
+    $tmpl = TWiki::Func::renderText($tmpl, "", $meta);
+    $tmpl = "$header$tmpl";
     $tmpl =~ s/.*?<\/nopublish>//gs;
     $tmpl =~ s/%MAXREV%/$maxrev/g;
     $tmpl =~ s/%CURRREV%/$maxrev/g;

-- TWiki:Main/JohnVestrum - 2010-08-19

ItemTemplate
Summary using STARTPUBLISH removes headers, defeats sendmail
ReportedBy TWiki:Main.JohnVestrum
Codebase

SVN Range TWiki-5.0.0, Tue, 06 Jul 2010, build 19208
AppliesTo Extension
Component MailerContrib
Priority Normal
CurrentState New
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Topic revision: r1 - 2010-08-19 - JohnVestrum
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback