My Perl / cgi script gets data from the webform in this way
The script gets data from a webform then prints back to the browser, creates a PDF Document and sends an email with the PDF document as an attachment
The script is long so i've only printed what i think you'l need here - i hope
#!/usr/bin/perl
use strict;
use CGI ':standard';
use PDF::API2;
use MIME::Lite;
use utf8;
$Name = param('name');
$Email = param('email');
$Subject = param('subject');
$Contents = param('contents');
If the users data entered into the variable $Contents contains spaces between lines or paragraphs, these blank lines are removed somewhere during the process of printing it back to the browsers screen and into a PDF Document and the email
Simplistically its printed back to the browser:
print "Content-Type:text/html\n\n";
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.or
+g/TR/xhtml11/DTD/xhtml11.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head></head>
<body>
<p>Thank you $Name for your message entitled $Subject</p>
<br>
<p>Your Message was:</p>
<br />
<p>$Contents</p>
<br />
<p>I will contact you as soon as possible if a response is required.</
+p>
<br />
<h2>$MyName</h2>
<br />
<br />
<br />
</body
</html>
And Printed into the PDF Document:
$txt->font($fnt, 8);
$txt->translate(25,740);
$txt->fillcolor('black');
$txt->text("$Contents");
And added to an email:
my $Message = "
<p>Thank you $Name for your email.</p>
<p>Subject: $Subject</p>
<p>Your Message was:</p>
<p>$Contents</p>
";
my $msg = MIME::Lite->new (
From => $From,
To => $To,
Subject => "Subject: re: $Subject",
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
###### Add the text message part
#
$msg->attach (
Type => 'HTML',
Data => "$Message",
) or die "Error adding the text message part: $!\n";
##### Send the Message
$msg->send;
|