Dennis G. Wicks wrote:
We now return you to the original problem!

What's that about? Oh, yeah... ;-)

I got the sample that Gunnar posted using Mail::Sender to work after I played around with cpan and got it installed.

Now I have discovered a new problem. The SMTP server does not respond on the first try all the time. (I think this is a local problem, but I need to replace my gateway/firewall server to solve ti.) It returns a message

    Cannot send mail: Service not available. Reply:

<snip>

Now the question is, how can I trap that error message from the Mail::Sender module and repeat as needed?

Try this:

my $sender = Mail::Sender->new( {
    smtp  => 'smtpout.secureserver.net',
    port  => '3535',
    from  => 'w...@mgssub.com',
} );
ref $sender or die
  "Object creation failed: $Mail::Sender::Error\n";

for my $try (1..4) {
    if ( ref( $sender->MailMsg( {
        auth    => 'LOGIN',
        authid  => 't...@mgssub.com',
        authpwd => 'mypasswd',
        to      => 'den...@wicksclan.com',
        subject => 'Yet another test!',
        msg     => $msg,
    } ) ) ) {
        print "Message was sent.\n";
        last;
    } else {
        warn "Send attempt $try. $sender->{'error_msg'}\n";
        $try == 4 ? die 'I give up' : sleep 10;
    }
}

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to