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

#!/fellow/monks.pl

Any ideas why my "die" portion doesn't executed, even when I specify incorrect details in my %param hash?

$pop = new Mail::POP3Client( USER => "$param{user}", PASSWORD => "$param{password}", HOST => "$param{server}" ) || die "Couldn't con +nect to $param{server} with $param{user}";

Thanks!

#!/massyn.pl The more I learn, the more I realize I don't know. Albert Einstein 1879-1955

Replies are listed 'Best First'.
Re: Mail::POP3Client doesn't quit on error
by tachyon (Chancellor) on Dec 24, 2002 at 04:28 UTC

    You need to do this check afterwars to determine connection status:

    unless($pop->Message =~ m/^\+OK/){ ($pop->Message =~ m/ERR(.*)/) ? show_login("$CONNECTION_FAILED: $1") : show_login("$CONNECTION_FAILED:" . $pop->Message); }

    The RE just trims the usual ERR Connection failed to 'Connection Failed' or gives the full error if it is unusual. On the note of Webmail client apps if you are writing one I have some code you may be interested in. It is a full blown webmail app with mutlilingual support, HTML mail reader, attachments etc. It also has Outlook type folders, folder tree display, address book, task list, calendar and even SMS messaging with POP3/MySQL backend.

    We have been using it ourselves for some months and it is quite stable. Drop me a /msg if you want to have a look at the API or the code. It has a pretty solid config script as well which makes it easy to install. I have been meaning to package it up for a while.....

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I'm actually busy with some kind of a mail robot, and I just need to check if the POP3 connection was ok.

      I'd like to see your webmail program. My next step would be to handle attachments, HTML text, etc.

      Thanks!