hi
Im new to Perl.
Im trying to write a program to send an e-mail via my cgi script. I tried various options - MIME::Lite, Sendmail, Mail::Sender, and none seem to work.
I get no error message in the Server Log file, but I dont receive an e-mail either. I suspect that it cant establish a connection to the SMTP server. Is there a way of knowing what communication happens with the SMTP server. The code I use is as below:
Thanks for your help.
Amy
Im new to Perl.
Im trying to write a program to send an e-mail via my cgi script. I tried various options - MIME::Lite, Sendmail, Mail::Sender, and none seem to work.
I get no error message in the Server Log file, but I dont receive an e-mail either. I suspect that it cant establish a connection to the SMTP server. Is there a way of knowing what communication happens with the SMTP server. The code I use is as below:
Thanks for your help.
Amy
Code:
#!C:\Perl\bin\perl.exe
use CGI::Carp qw(fatalsToBrowser);
use Mail::Sender;
use Net::SMTP;
print "Content-type: text/html\n\n";
my $relay = "xxx.xxx.edu";
my $smtp = Net::SMTP->new($relay)
|| die "Can't open mail connection: $!";
my $to='xxx\@cs.xxx.edu';
my $from='xxx\@cs.xxx.edu';
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
foreach $body (@body) {
$smtp->datasend("$body\n");
}
$smtp->dataend();
$smtp->quit();
open my $DEBUG, ">> debugfile.txt"
or die "Can't open the debug file: $!\n";
$sender = new Mail::Sender
{smtp => 'mail.cs.xxx.edu', from => 'xxx@cs.xxx.edu'};
$sender->MailFile({to => 'xxx@cs.xxx.edu',
subject => 'Here is the file',
msg => "I'm sending you the list you wanted.",
debug => $DEBUG,
debug_level=>3,
authid=>'xxx',
authpwd=>'pwd'
});
$sender->SendEnc;
$sender->Close;