use Email::Filter; use Mail::Sendmail; BEGIN { $mail = Email::Filter->new(); $mail->exit(0); } my $to = $mail->to; my $from = $mail->from; my $subject = $mail->subject; my $body = $mail->body; open (LOG, qq|>>MAIL.txt|); print LOG qq|TO => $to\n|; print LOG qq|FROM => $from\n|; print LOG qq|SUBJECT => $subject\n|; print LOG qq|BODY => $body\n|; close (LOG); END { my %hash = ( to => $from , from => 'foo@bar.com' , subject => 'Mail recieved' , body => 'Your message has been received' , smtp => 'foobar.com' ); open(ERROR, qq|>>ERROR.txt|); sendmail(%hash) or print ERROR qq|Couldn't send mail... $!\n|; #uncomment following lines for debugging only print ERROR qq|$Mail::Sendmail::error \n|; print ERROR qq|\$Mail::Sendmail::log says:\n$Mail::Sendmail::log\n|; close (ERROR); $mail->exit(1); $mail->accept('/dev/null'); }