Dalin has asked for the wisdom of the Perl Monks concerning the following question:

Hey all, I'm using the Mail::Sender module in a program that i wrote to make changes to some acl files and atumatically mail the affected users through smtp. The program is almost working except for the actual mailing. When I run the program, I make my file changes, and from there the Mail::Sender module takes over. I got no mail though. When I check my syslog, I see the following:
Jun 26 10:11:22 huma sendmail[2348]: f5QEBMv02348: lost input channel +from local host [127.0.0.1] to Daemon0 after data Jun 26 10:11:22 huma sendmail[2348]: f5QEBMv02348: from=<nobody.domain +.com>, size=0, class=0, nrcpts=0, proto=SMTP, daemon=Daemon0, relay=localhos +t [127.0.0 .1]
Here is my sub that handles the actual mailing:
sub sender_mail { no strict "refs"; my ($user1,$diff1) = @_; my $body_file = "/usr/local/squid/etc/aclfiles/letter"; open (BODY_FILE,$body_file); my @body = <BODY_FILE>; close (BODY_FILE); my $from = "nobody.domain.com"; my $subj = "Web access changes."; my $sender; ($sender = new Mail::Sender ({ from => $from, smtp => 'localhost'})) || die "$!"; ($sender->MailFile( { to => $user1, subject => $subj, msg => "@body", file => $dif +f1 })) }
If you need to see the rest of the code, let me know. I would greatly appreciate any help anyone can give to me on this one. Thanks in advance, Bradley
Where ever there is confusion to be had... I'll be there.

Replies are listed 'Best First'.
Re: Mail::Sender question
by nardo (Friar) on Jun 26, 2001 at 19:34 UTC
    On my machine, Mail::Sender's msg is a scalar not an array, try reading the file into $body rather than @body.
Re: Mail::Sender question
by chromatic (Archbishop) on Jun 26, 2001 at 23:29 UTC
    Use error checking to your advantage. The 'size=0' in log makes me wonder if the file open succeeds:

    open(BODY_FILE, $body_file) or die "Can't open $body_file: $!";

    Mail::Sender also provides error codes.

    if (!(ref($sender) and ($sender < 0)) { die "Sender error: $sender, $Mail::Sender::Error!\n"; }
    Otherwise, things look reasonably correct.