A
alamukutty
Hi,
I am pretty new to cgi-perl and I'm trying to process a form and
send the email using sendmail. I figured how to send attachments using
MIME::Lite and also figured how to process a form and send a plain
text mail like
for each param()
ParamName = Param vAlue
When I try to put the two together, I am stuck. I don't know how to
process strings with perl and any help will be appreciated.
For now, this is what I am trying and I get a server error.
----------------------
#! / usr/bin/perl -w
use CGI qw
standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
use lib '/usr/lib/perl5/site_perl/5.8.0/MIME';
use MIME::Lite;
print start_html("Thank You");
# Set the PATH environment variable to the same path
# where sendmail is located:
$ENV{PATH} = "/usr/sbin";
# Now print the body of your mail message.
my $body_string;
foreach my $p (param()) {
$body_string = print "$p = ", param($p), "\n";
}
my $msg = MIME::Lite->new(
Subject =>'Form Data!',
Type =>'multipart/mixed',
);
$msg->attach(
Type => 'TEXT',
Data => $body_string );
$msg->attach(
Type =>'application/msword',
Path => '/usr/local/apache2/htdocs/checking.doc'
);
$msg->send();
# Be sure to close the MAIL input stream so that the
# message actually gets mailed.
# Now print a thank-you page
print <<EndHTML;
<h2>Thank You</h2>
<p>Your information has been submitted.</p>
<p>Return to our <a href="index.htm">home page</a>.</p>
EndHTML
print end_html;
I am pretty new to cgi-perl and I'm trying to process a form and
send the email using sendmail. I figured how to send attachments using
MIME::Lite and also figured how to process a form and send a plain
text mail like
for each param()
ParamName = Param vAlue
When I try to put the two together, I am stuck. I don't know how to
process strings with perl and any help will be appreciated.
For now, this is what I am trying and I get a server error.
----------------------
#! / usr/bin/perl -w
use CGI qw
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
use lib '/usr/lib/perl5/site_perl/5.8.0/MIME';
use MIME::Lite;
print start_html("Thank You");
# Set the PATH environment variable to the same path
# where sendmail is located:
$ENV{PATH} = "/usr/sbin";
# Now print the body of your mail message.
my $body_string;
foreach my $p (param()) {
$body_string = print "$p = ", param($p), "\n";
}
my $msg = MIME::Lite->new(
To =>[email protected]',From =>'(e-mail address removed)',
Subject =>'Form Data!',
Type =>'multipart/mixed',
);
$msg->attach(
Type => 'TEXT',
Data => $body_string );
$msg->attach(
Type =>'application/msword',
Path => '/usr/local/apache2/htdocs/checking.doc'
);
$msg->send();
# Be sure to close the MAIL input stream so that the
# message actually gets mailed.
# Now print a thank-you page
print <<EndHTML;
<h2>Thank You</h2>
<p>Your information has been submitted.</p>
<p>Return to our <a href="index.htm">home page</a>.</p>
EndHTML
print end_html;