Skip to Content.
Sympa Menu

en - Re: [sympa-users] How to compose a multipart/alternative mail

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: Adam Bernstein <address@concealed>
  • To: Barry Flanagan <address@concealed>
  • Cc: address@concealed
  • Subject: Re: [sympa-users] How to compose a multipart/alternative mail
  • Date: Sun, 23 Apr 2006 14:13:01 -0700

That would be ideal. I think it would be a great addition to Sympa. I'd
be happy to take the patch in the meantime ;-)

Okay, here it is -- like I said, a little ugly. Attached is a patch to wwsympa.fcgi to incorporate the HTML input, a patch to mail.pm because it needs to change the Content headers it's sending (my technique is for wwsympa to fully format the multipart message, and then mail.pm searches the data for the MIME part separator string that I've used and sets the headers accordingly), and a custom version of the compose_mail.tt2 template that has the HTML input box and instructions added. Actually I also added a simple "send test message to me" function to my code, but I've removed that from this patch to keep it simple and because it's not that useful a test -- it does show the final MIME multipart formatting, but it doesn't do any of the header/footer or other Sympa processing.

Questions, comments, please feel free. It doesn't seem quite clean enough to submit for official Sympa consideration....

ab
*** wwsympa.fcgi.orig Sun Apr 23 13:55:37 2006
--- wwsympa.fcgi Sun Apr 23 14:01:03 2006
***************
*** 429,434 ****
--- 429,435 ----
'content' => '.+',
'body' => '.+',
'info' => '.+',
+ 'htmlbody' => '.+', # used for HTML on Web posting page

## Integer
'page' => '\d+',
***************
*** 12332,12339 ****
$Text::Wrap::columns = 80;
$in{'body'} = &Text::Wrap::wrap ('','',$in{'body'});


! my @body = split /\0/, $in{'body'};

my $from = $param->{'user'}{'email'};
if ($param->{'user'}{'gecos'}) {
--- 12333,12352 ----
$Text::Wrap::columns = 80;
$in{'body'} = &Text::Wrap::wrap ('','',$in{'body'});

+ # Accepting HTML email on Post page:
+ my $inbody;

! if ($in{'htmlbody'}) {
! $in{'htmlbody'} =~ s/\015//g;
! my $boundary = sprintf "--===Web posting===";
! my $firstboundary = sprintf "%s\nContent-Type: text/plain;
charset=iso-8859-1\nContent-transfer-encoding: 8bit", $boundary;
! my $secondboundary = sprintf "%s\nContent-Type: text/html;
charset=iso-8859-1\nContent-transfer-encoding: 8bit", $boundary;
! $inbody =
"\n".$firstboundary."\n\n".$in{'body'}."\n\n".$secondboundary."\n\n".$in{'htmlbody'}."\n\n".$boundary."--\n";
! &wwslog('info','do_send_mail: %s',$inbody);
! } else {
! $inbody = $in{body};
! }
! my @body = split /\0/, $inbody;

my $from = $param->{'user'}{'email'};
if ($param->{'user'}{'gecos'}) {
*** mail.pm.orig Sun Apr 23 13:51:28 2006
--- mail.pm Sun Apr 23 13:55:08 2006
***************
*** 86,93 ****
printf $fh "%s: %s\n", $field,
MIME::Words::encode_mimewords($headers->{$field}, ('Encode' => 'Q', 'Charset'
=> $charset));
}
printf $fh "MIME-Version: 1.0\n";
! printf $fh "Content-Type: text/plain; charset=%s\n",
gettext("_charset_");
! printf $fh "Content-Transfer-Encoding: %s\n", gettext("_encoding_");
print $fh "\n";

if (ref($data) eq 'SCALAR') {
--- 86,100 ----
printf $fh "%s: %s\n", $field,
MIME::Words::encode_mimewords($headers->{$field}, ('Encode' => 'Q', 'Charset'
=> $charset));
}
printf $fh "MIME-Version: 1.0\n";
!
! # Look for multipart separator indicating HTML composed from Post page, and
! # set headers accordingly:
! if (ref($data) eq 'ARRAY' && $data->[0] =~ /--===Web posting===/) {
! printf $fh "Content-Type: multipart/alternative;
boundary=\"\===NPOGroups===\"\n";
! } else {
! printf $fh "Content-Type: text/plain; charset=%s\n",
gettext("_charset_");
! printf $fh "Content-Transfer-Encoding: %s\n", gettext("_encoding_");
! }
print $fh "\n";

if (ref($data) eq 'SCALAR') {

Post Message If you have permission to post to this group, you can do so here. However, the easiest way for you to send a message to the group may be to simply compose a message in your normal email software, addressed to [% list %]@[% host %], sent from an address that has permission to post. You can send formatted messages that way as long as the formatting is done in HTML; MS Outlook users should ensure that their formatting is not set to "Microsoft Rich Text", which will not be preserved.

[%|loc(user.email)%]From: %1[%END%]
[%|loc(mailto)%]To: %1[%END%]
[%|loc%]Subject:[%END%]

Plaintext message (required):



HTML message (optional -- know what you're doing!):
Enter plaintext above and text with raw HTML markup language here, and a multipart/alternative message will be sent using both the plaintext and HTML parts. Images can be used only by referencing their URLs on any Web server where they already reside. Leave this box blank if you want your plaintext to be readable by all.





Archive powered by MHonArc 2.6.19+.

Top of Page