Romeo Theriault wrote:
> Hello, I'm trying to send a variable in a email using Net::SMTP. For some
> reason no matter what I do the contents of the variable are not sent. I
> know the variable holds the information I want because if I do a
> 
> print $file;
> 
> the contents are printed. Here is the program. Thanks for any help.
> 
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> use Net::SMTP_auth;
> use Slurp;
> 
> my $file;     # variable to hold the contents of the file to read in.
> my $content;
> my $beancount = 0;  # variable to hold the count of any beans that have a
> fail.
> my @contents; # array to hold the failcount numbers
> my $infile = '/Users/romeo/Desktop/beancounter/user_beancounters';
> 
> open (IN, "<$infile") or die "Cannot open file for reading: $!";
> 
> while (<IN>) {
>    chomp; # remove new-line characters
>    if (/\s\w+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)/) {
>        push (@contents, $1); # for each regex match push it into the
> @contents array.
>    }
> }
> 
> foreach $content (@contents) {
>    if ($content > 0) {
>        $beancount = $beancount + 1;
>    }
> 
> }
> 
> if ($beancount > 0) {
>    $file = slurp($infile);

I don't have the Net::SMTP_auth or Slurp modules but I would like to point out
that you don't have to read the contents of the file $infile twice to do what
you want:

my $infile = '/Users/romeo/Desktop/beancounter/user_beancounters';

my $file = slurp( $infile );
if ( $infile =~ /\s\w+\s+\d+\s+\d+\s+\d+\s+\d+\s+([1-9]\d*)/g ) {


>    my $from = '[EMAIL PROTECTED]';
>    my $to = '[EMAIL PROTECTED]';
>    my $subject = "VZ beancounter error.";
>    my $smtp = Net::SMTP_auth->new('miranda.umfk.maine.edu');
>    $smtp->auth('LOGIN', 'user', 'password');

I read through RFC 2554 and RFC 2222 and I couldn't find the authentication
method 'LOGIN'.  Perhaps you should check for login errors?


>    $smtp->mail($from);
>    $smtp->to($to);
>    $smtp->data();
>    $smtp->datasend("To: $to\n");
>    $smtp->datasend("Subject: $subject\n");
>    $smtp->datasend($file);
>    $smtp->dataend();
> 
>    $smtp->quit;
> }
> #print $file; # this actually prints the file
> close(IN);



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to