in reply to Re^3: Failed Mail::Mailer on AIX 5.3
in thread Failed Mail::Mailer on AIX 5.3

I decided on Mail::Sendmail. I used CPAN to install and it looks fine. I created a small test program as follows:

#!/usr/bin/perl #
use strict;
use warnings;
use Mail::Sendmail;

%mail = ( To => 'burtonk@chesterfield.gov',
From => 'burtonk@chesterfield.gov',
Subject => 'Test email from Perl',
Message => "This is a test message from PERL !!"
);

sendmail(%mail) or die $Mail::Sendmail::error;

print "OK. Log says:\n", $Mail::Sendmail::log;

exit ;

When I go to run it:

Global symbol "%mail" requires explicit package name at ./emailit.pl line 14.
Global symbol "%mail" requires explicit package name at ./emailit.pl line 20.

What am I missing, the syntax looks fine?
Ken

Replies are listed 'Best First'.
Re^5: Failed Mail::Mailer on AIX 5.3
by Corion (Patriarch) on Mar 16, 2010 at 17:26 UTC

    The strict pragma requires you to predeclare all variables you're going to use, to protect you against typos and misspellings of variable names. You have not predeclared your use of %mail and hence strict complains. You might want to use the vars pragma to predeclare variables:

    use vars qw[%mail];
      Thank you so much, Corion!! That worked and the email is functioning. Ken