I have this perl script, all it does is open a file with email addresses in it and sends an email to each one.

what I want to do is have a check to see if the email has actually sent. either display on the screen or write it to another file.

I am not big on perl so could someone help me out? yes it does take info from a form, this form is made in php and all that part works, just need to verify to the admin that the emails were sent. not just show a sent message.

I have tried to print the email tha twas sent to the screen in the foreach loop but you never se it as all you see is the sent message. maybe save the sent email to a file would also work.
PHP Code:
#!/usr/bin/perl 

$sendmail '/usr/sbin/sendmail'

read(STDIN$buffer$ENV{'CONTENT_LENGTH'}); 
@
pairs split(/&/, $buffer); 
foreach 
$pair (@pairs) { 
    (
$name$value) = split(/=/, $pair); 
    
$value =~ tr/+/ /; 
    
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C"hex($1))/eg
    if (
$INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; } 
    else { 
$INPUT{$name} = $value; } 

$file_to_open $ENV{"DOCUMENT_ROOT"}."/".$INPUT{'address_file'}; 
$pid fork(); 
print 
"Content-type: text/html \n\n fork failed: $!" unless defined $pid

if (
$pid) { 

print 
"Content-type: text/html \n\n"
        print 
"<html><head><title>Mail Manager</title></head><body> 
    <br /><br /><br /><div align=\"center\"> 
    <table width=\"280\"><tr><td width=\"280\" valign=\"top\"> 
    <table width=\"280\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\" bordercolor=\"#808080\" bordercolorlight=\"black\" bordercolordark=\"white\"> 
    <tr><td bgcolor=\"#0000A0\"><span style=\"font-face:arial; size:12; color:white\"><b>Send Status</b></td></tr> 
    <tr><td bgcolor=\"#C0C0C0\"><span style=\"font-face:arial; size:12;\"> 
    <br /><div align=\"center\">Success!<BR>The messages were sent.<br /><br /> File used in process: 
$INPUT{'address_file'} 
    <br /><br /><button onclick=\"history.back(-1)\" >Back </button></td></tr> 
    </table> 
    </td> 
    </tr></table></div> 
    </body> 
    </html>"

    exit(
0); 

else { 

    
close (STDOUT); 
    
open(LIST, "$file_to_open") || die "Cannot open Address File $file_to_open!"
    @
addresses=<LIST>; 
    
close(LIST); 

    foreach 
$line(@addresses) { 
        
chomp($line); 

        
open(MAIL"|$sendmail -t") || &error("Could not send out emails"); 
        print 
MAIL "To: $line \n"
        print 
MAIL "From: $INPUT{'from'} <$INPUT{'from'}>\n"
        print 
MAIL "Subject: $INPUT{'subject'}\n"

        print 
MAIL "MIME-Version: 1.0\n"
        print 
MAIL "Content-Type: text/html;\n"
        print 
MAIL "Content-Transfer-Encoding: 7bit\n\n"

        print 
MAIL "$INPUT{'main_message'}"
        print 
MAIL "\n\n"

        print 
MAIL "\n\n"
        
close (MAIL); 

    }