# Plain text output:
This is some text to test the wrapping feature of Text::Correct's wrap(), using MIME::Lite to create the message.
I really just want to have two lines of data to test the functions and want them both to be over the 72 character limit.
# HTML output:
<p>This is some text to test the wrapping feature of Text::Correct's wrap(), using MIME::Lite to create the message.</p>
<p>I really just want to have two lines of data to test the functions and want them both to be over the 72 character limit.</p>
####
# Plain text output:
This is some text to test the wrapping feature of Text::Correct's
wrap(), using MIME::Lite to create the message.
I really just want to
have two lines of data to test the functions and want them both to be
over the 72 character limit.
# HTML output:
<p>This is some text to test the wrapping feature of Text::Correct's
wrap(), using MIME::Lite to create the message.</p>
<p>I really just
want to have two lines of data to test the functions and want them both
to be over the 72 character limit.</p>
####
Content-Type: text/plain
This is some text to test the wrapping feature of Text::Correct's
I really just want toite to create the message.
have two lines of data to test the functions and want them both to be
over the 72 character limit.
------
Content-Type: text/html
<p>This is some text to test the wrapping feature of Text::Correct's
<p>I really justME::Lite to create the message.</p>
want to have two lines of data to test the functions and want them both
to be over the 72 character limit.</p>
####
#!/usr/local/bin/perl -w
use CGI;
use strict;
my $q = new CGI;
my $emailoutput = '/tmp/email.data';
use MIME::Lite;
use Text::Correct qw{ wrap };
my $tp = $q->param('textPLAIN')."\n";
my $th = $q->param('textHTML')."\n";
# Section just for debugging (output to files and browser)
print $q->header;
print "plain pre:
\n $tp
\n";
print "html pre:
\n $th
\n";
open O,">/tmp/o1";
print O $tp;
close O;
open O,">/tmp/o2";
print O $th;
close O;
my $wtp = wrap(' ','',$tp);
my $wth = wrap(' ','',$th);
# More debugging (output to files and browser)
open O,">/tmp/o3";
print O "$wtp";
close O;
open O,">/tmp/o4";
print O "$wth";
close O;
print "plain post:
\n $wtp
\n";
print "html post:
\n $wth
\n";
# Start the message
my $msg = MIME::Lite->new(
From =>$q->param('emailFrom'),
To =>$q->param('emailTo'),
Subject =>$q->param('emailSubject'),
Type =>'multipart/alternative',
);
$msg->attach(
Type =>'TEXT',
Data =>"$wtp\n",
);
$msg->attach(
Type =>'text/html',
Data =>"$wth\n",
Encoding =>'7bit',
);
# Add character set (required header)
$msg->attr("content-type.charset" => "US-ASCII");
# Remove headers (another requirement)
$msg->scrub(['content-transfer-encoding','content-disposition']);
# Final output of script to file (yet another requirement)
open(OUTFILE,">$emailoutput") or die "Unable to open $emailoutput: $!";
$msg->print(\*OUTFILE);
close OUTFILE;