Great Circle Associates Majordomo-Users
(November 2007)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: message_footer etc
From: "Robert Doty" <rdoty @ psasm . biz>
Date: Wed, 7 Nov 2007 12:01:39 -0500
To: "'Julian H. Stacey'" <jhs @ berklix . org>, <majordomo-users @ greatcircle . com>
In-reply-to: <200711071546 . lA7FkSZQ006615 @ fire . js . berklix . net>
References: <473114D3 . 3000705 @ scaseyllc . com> <200711051033 . 45788 . mr . domo @ dahl-stamnes . net> <4730ED60 . 7020707 @ sonny . org> <473114D3 . 3000705 @ scaseyllc . com> <5 . 1 . 1 . 6 . 2 . 20071107075338 . 03b69d18 @ 127 . 0 . 0 . 1> <200711071546 . lA7FkSZQ006615 @ fire . js . berklix . net>
Thread-index: AcghV4Bk1xsueoUKRm2l1LQtlLEm4gAAJZfw

Julian,

>The real solution would be to extend majordomo to be MIME aware
>	- More modern mail list tools such as Mailman are MIME aware.
>	- Is Majordomo-2 MIME aware ?

You are absolutely correct here.  The solution I have interprets the MIME
and in my experience is 99%+ successful.

>Sounds useful.
>Hopefuly the Ascii footer doesnt get sent too on HTML postings, as double
footers would confuse some people on some lists I run:
>	( Who are more than confused enough already), Some are total
>	  incompetents, can't understand ascii, or subscribe addresses
>	  etc, hence I'm constantly tempted to switch to Mailman,
>	  to avoid dealing with them ).

The solution will result in the HTML footer within the HTML section and the
Text footer within the Text portion of the message.  

OK.  Here is a bulk of what you need.  Hopefully you know perl and can make
it all work for you.  Feel free to bounce questions off of me.

In config_parse.pl, you will need to make duplicates for all
"message_footer" entries and rename them html_footer.

Add these lines to your .config files:

        # html_footer          [string_array] (undef) <resend,digest>
        # Text to be appended at the end of all messages posted to the
        # list. The text is expanded before being used. The following
        # expansion tokens are defined: $LIST - the name of the current
        # list, $SENDER - the sender as taken from the from line, $VERSION,
        # the version of majordomo. If used in a digest, no expansion
        # tokens are provided
	html_footer         <<  END
	<p>
	Some message here
	</p>
END


Comment out or delete the following from "resend":

># Print out any message_footers
>#
>print STDERR "$0: adding any footers.\n" if $DEBUG;
>
>if ( $config_opts{$opt_l,"message_footer"} ne '' ) {
>    local($footer) =
>        &config'substitute_values(
>            $config_opts{$opt_l,"message_footer"}, $opt_l);   #'
>    $footer =~ s/\001|$/\n/g;
>    print OUT $footer;
>}

Next, in the original "resend" script you will find this:

	# open our tmp file
	#
	open(MAILIN, "$TMPDIR/resend.$$.out");

	# spit it out!
	#
	while (<MAILIN>) {
	    print MAILOUT $_;
	}

	# cleanup
	#
	close(MAILIN);

You want to add these lines above this section:

> $foundmime=0;
> $foundboundary=0;
> $dontoutput=0;
> $btext=$btext2="=JustAnotherSeparator="; 
> if ($html_footer eq "")
> {
> 	if ( $config_opts{$opt_l,"html_footer"} ne '' ) {
> 	    $html_footer = 
> 		&config'substitute_values(
> 		    $config_opts{$opt_l,"html_footer"}, $opt_l);   #'
> 	    $html_footer =~ s/\001|$/\n/g;
> 	}
> }	
> if ($message_footer eq "")
> {
> 	if ( $config_opts{$opt_l,"message_footer"} ne '' ) {
> 	    $footer = 
> 		&config'substitute_values(
> 		    $config_opts{$opt_l,"message_footer"}, $opt_l);   #'
> 	    $footer =~ s/\001|$/\n/g;
> 	}
> }
> 
> 
> 

Then, you want to replace the one liner within the while loop:
     print MAILOUT $_;

With all of this:
> 	if ( /boundary=/ )
> 	{
> 		if ( $foundboundary == 0 )
> 		{
> 			( $junk, $btext ) = split ( /boundary=/, $_, 2);
> 			$btext =~ s/"//g;
> 			$btext =~ s/\n//g;
> 			$foundboundary=1;
> 		}
> 		else
> 		{
> 			( $junk, $btext2 ) = split ( /boundary=/, $_, 2);
> 			$btext2 =~ s/"//g;
> 			$btext2 =~ s/\n//g;
> 			$foundboundary=2;
> 		}
> 	}
> 	if ( $foundmime == 0 )
> 	{
> 		if ( /$btext/ || /$btext2/ )
> 		{
> 			$ignoreattachment=0;
> 			print STDERR ("Found MIME separater\n");
> 			$foundmime=1;
> 			$plaintext=0;
> 		}
> 		if (/<html>/)
> 		{
> 			$noboundaryhtml=1;
> 			print STDERR ("Found noboundary html\r\n");
> 			if (/<\/html>/)
> 			{
> 				print STDERR ("single line html\r\n");
> 			}
> 
> 		}
> 		if (/<\/html>/ && $noboundaryhtml==1)
> 		{
> 			print STDERR ("noboundary html end\r\n");
> 			( $body, $junk ) = split ( /<\/html>/, $_, 2);
> 			print MAILOUT $body;
> 			print MAILOUT $html_footer;
> 			print MAILOUT "<\/html>";
> 			$dontoutput=1;
> 		}
> 	}
> 	elsif ( $plaintext == 0 && $htmltext == 0 )
> 	{
> 		if ( /Content-Type:/ )
> 		{
> 			if ( /[Pp][Ll][Aa][Ii][Nn]/ )
> 			{
> 				print STDERR ("Found plain/text section\n");
> 				$plaintext=1;
> 			}
> 			if ( /[Hh][Tt][Mm][Ll]/ )
> 			{
> 				print STDERR ("Found plain/html section\n");
> 				$htmltext=1;
> 				$bodybegin=0;
> 			}
> 			if ( /[Mm][Ss]-[Tt][Nn][Ee][Ff]/)
> 			{
> 				print STDERR ("Found TNEF\n");
> 				print MAILOUT<<"EOF";
> Content-Type: text/plain;
> 	name="TNEF AttachmentRemoved.txt"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: attachment;
> 	filename="TNEF AttachmentRemoved.txt"
> 
> The TNEF Attachment was removed because it is not supported by this 
> service.  Please try sending your message in plain text.  For more 
> information on TNEF, please google it and you will learn a lot.
> 
> Thank-you,
> 
> Rob
> 
> EOF
> 				$ignoreattachment=1;
> 			}
> 			$encoding="";
> 		}
> 	}
> 	else
> 	{
> 		if ( $encoding eq "" )
> 		{
> 			if ( /Encoding/ )
> 			{
> 				print STDERR "Encoding Found\n";
> 				if ( /7bit/ )
> 				{
> 					$encoding="7bit";
> 				}
> 				elsif ( /8bit/ )
> 				{
> 					$encoding="8bit";
> 				}
> 				elsif ( /quoted/ )
> 				{
> 					$encoding="qp";
> 					if ($htmltext == 1)
> 					{
> 						print STDERR "QP Found.
Altering footer\n";
> 						$html_footer =~ s/=/=3D/g;
> 					}
> 				}
> 			}
> 		}
> 		if ( $htmltext == 1 )
> 		{
> 			if ( /$btext/ || /$btext2/  )
> 			{
> 				print STDERR ("No Body End.  Inject html
footer\n");
> 				print MAILOUT $html_footer;
> 				print MAILOUT "\n\n";
> 				$htmltext=0;
> 				$waitforbodyend=0;
> 			}
> 			elsif ( /HTML>/ || /html>/  )
> 			{
> 				if ( $htmlbegin==0 )
> 				{
> 					$htmlbegin=1;
> 					print STDERR ("Found HTML
Beginning\n");
> 				}
> 				else
> 				{
> 					( $rest, $body ) = reverse split (
/<\/[Hh][Tt][Mm][Ll]>/, $_, 2);
> 					if ($waitforbodyend == 0)
> 					{
> 						print MAILOUT $body;
> 					}
> 					print MAILOUT $html_footer;
> 					print MAILOUT
"<\/BODY><\/HTML>\n\n";
> #					print MAILOUT $rest;
> 					$dontoutput=1;
> 					$waitforbodyend=0;
> 					$htmltext=0;
> 				}
> 			}
> 			elsif ( /<[Bb][Oo][Dd][Yy]/ )
> 			{
> 				if ( $bodybegin==0 )
> 				{
> 					$bodybegin=1;
> 					print STDERR ("Found Body
Beginning\n");
> 				}
> 			}
> 			elsif ( !/[Tt][Bb][Oo][Dd][Yy]>/ &&
/[Bb][Oo][Dd][Yy]>/ && $bodybegin == 1 )
> 			{
> 				( $rest, $body ) = reverse split (
/<\/BODY>/, $_, 2);
> 				print STDERR "Found Body End.  Inject HTML
Footer\n";
> 				print STDERR "body: $body\nrest: $rest\n";
> 				if ($waitforbodyend == 0)
> 				{
> 					print MAILOUT $body;
> 				}
> 				print MAILOUT $html_footer;
> 				print MAILOUT "<\/BODY><\/HTML>\n\n";
> 				$dontoutput=1;
> 				$waitforbodyend=0;
> 				$htmltext=0;
> 			}
> 			elsif ( /INCREDIFOOTER/ )
> 			{
> 				print MAILOUT "</TR></TBODY></TABLE>\n";
> 				$waitforbodyend=1;
> 			}
> 		}
> 		elsif ( $plaintext == 1 )
> 		{
> 			if ( /$btext/  || /$btext2/ )
> 			{
> 				print STDERR ("Printing footer\n");
> 				print MAILOUT ("$footer\n");
> 				if ( $encoding eq "qp" )
> 				{
> 					print MAILOUT ("=20\n");
> 				}
> 				$plaintext=0;
> 			}
> 		}
> 	}
> 	if ( $dontoutput == 0 && $ignoreattachment == 0 && $waitforbodyend
== 0 )
> 	{
> 		if ( /Check out the new AOL/ || /search.msn.com/ ||
/local.live.com/ || /Yahoo!/ || /mail.yahoo.com/ || /us.rd.yahoo.com/ ||
/Get your email/ || /www.imagine-windowslive.com/ || /spaces.live.com/ ||
/clk.atdmt.com/ )
> 		{
> 			print STDERR "Skipping: $_\n";
> #			$waitforbodyend=1;
> #			if (/Yahoo/ && $plaintext == 0)
> #			{
> #				($mess, $junk) = split ("Do You Yahoo!", $_,
2);
> #				print MAILOUT $mess;
> #				print MAILOUT "<br><hr>\n";
> #			}
> 			print MAILOUT $_;
> 		}
> 		else
> 		{
> 			print MAILOUT $_;
> 		}	
> 	}
> 	else
> 	{
> 		$dontoutput=0;
> 	}

Please let me know if you have any questions.

Thanks,

Rob


------------------------------------------------------
Owner, Rochester Classifieds Online
http://RochesterClassifiedsOnline.biz
------------------------------------------------------ 



References:
Indexed By Date Previous: Re: message_footer etc
From: "Julian H. Stacey" <jhs @ berklix . org>
Next: Re: message_footer etc
From: Sean Casey <mj @ scaseyllc . com>
Indexed By Thread Previous: Re: message_footer etc
From: "Julian H. Stacey" <jhs @ berklix . org>
Next: Re: message_footer etc
From: Sean Casey <mj @ scaseyllc . com>