Chris Marshall wrote:

I'm trying to use Test::Reporter with Net::SMTP::TLS
and having no luck.  If someone has gotten this to
work (especially with gmail smtp), I would appreciate
the working template for use.

Here's a script I'm using to send reports via google.

I'm using "transport=File" to store reports in directory and run this script from it once a day, because gmail accepts only 500 messages to one recipient per day, and smokers often go over the limit.

--
Serguei Trouchelle
#!/usr/bin/perl -w

use strict;
use warnings;

use Test::Reporter;


$| = 1;

opendir(my $DIR, '.') or die $!;
my @files = sort { my @aa = stat($a); my @bb = stat($b); $aa[10] <=> $bb[10] } 
grep { /\.rpt$/ } readdir $DIR;
closedir $DIR;

print 'Found ', scalar @files, ' files, sending ';
foreach my $file (@files) {
    my $tr = Test::Reporter->new(
        'mx' => ['smtp.gmail.com'],
        'transport' => 'Net::SMTP::TLS',
        'transport_args' => [
            'User'     => '[email protected]',
            'Password' => 'PASSWORD',
        ],
    )->read( $file );

    my $res = $tr->send();

    print '.';

    if ($tr->errstr()) {
        print "\n\n", $tr->errstr();
        if ($tr->errstr() =~ /Daily quota/) {
            last;
        }
        sleep 60;
        redo;
    }
    unlink $file;
}

print "\n\n";

Reply via email to