I have this script mentioned below. When I run it from command line: perl test.cgi all works as it should. When I run it from my browser it only writes the file displays the confirmation, but does NOT email my files. From command line everything works.
#!/usr/bin/perl
use CGI qw(:standard);
use lib "/home/staff/wot/public_html/perl/MIME-Lite-3.01_04/lib/"; use MIME::Lite; use Net::SMTP;
print "Content-type: text/html\n\n";
open(test123, ">>/home/staff/wot/public_html/perl/test.csv") or die ("File test.csv could not be opened for writing");
$surname = param("surname"); $name = param("forename"); $email = param("email");
print "<p><b>The following details have been captured by our system\n</b></p>";
print "<p><b>Surname:</b>$surname\n</p>";
print "<p><b>Name:</b>$name\n</p>";
print "<p><b>Email:</b>$email</p>";
flock(test, 2); seek(test, 0, 2);
print test123 "$surname,$name,$email\n";
close(test);
my $from_address = '[EMAIL PROTECTED]'; my $to_address = '[EMAIL PROTECTED]'; my $mail_host = 'smtp.dcs.kcl.ac.uk';
my $subject = 'Test Subject'; my $message_body = "Attachment file(s) test";
my $my_file_gif = 'logo.gif'; my $your_file_gif = 'logo.gif'; my $my_file_zip = 'running.pdf'; my $your_file_zip = 'running.pdf';
$msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n";
$msg->attach ( Type => 'TEXT', Data => $message_body ) or die "Error adding the text message part: $!\n";
$msg->attach ( Type => 'image/gif', Path => $my_file_gif, Filename => $your_file_gif, Disposition => 'attachment' ) or die "Error adding $file_gif: $!\n";
$msg->attach ( Type => 'application/zip', Path => $my_file_zip, Filename => $your_file_zip, Disposition => 'attachment' ) or die "Error adding $file_zip: $!\n";
MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send;
Any ideas?
Regards Otto
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>