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

Hi Gargle, Thanks for your advice. I've changed the code slightly to test send(). However the code always prints Success. I'm a bit of a novice at perl, so I'm sorry if I don't quite understand what is going wrong..... Cheers Shaun
#!/usr/bin/perl # use strict; use warnings; use Net::SMTP; use MIME::Lite; sub main { my ($rcpt,$fn) = @_; my $msg; $msg = MIME::Lite->new( To =>$rcpt, From =>'delps.demo%marviq.com', Subject =>'Click and Claim faxprobleem', Type =>'multipart/mixed' ); $msg->attach( Type => 'text/html', Encoding => 'quoted-printable', Path =>$fn ); if ($msg->send()) { print "Success\n"; } else { print "Failed\n"; } } exit (&main(@ARGV) ? 0 : -1);

Replies are listed 'Best First'.
Re: Getting the exit status from a pm
by gargle (Chaplain) on Sep 12, 2005 at 09:59 UTC

    Hi,

    From cpan: Mine::Lite:

    As an instance method with no arguments, sends the message by the default mechanism set up by the class method. Returns whatever the mail-handling routine returns: this should be true on success, false/exception on error.

    --
    if ( 1 ) { $postman->ring() for (1..2); }
Re: Getting the exit status from a pm
by gargle (Chaplain) on Sep 12, 2005 at 12:00 UTC

    Hi,

    Don't you need to set the principal method of sending mail beforehand?

    MIME::Lite->send('sendmail', "d:\\programs\\sendmail.exe"); ... $msg = MIME::Lite->new(...);

    On unix this is the default:

    MIME::Lite->send("sendmail", "/usr/lib/sendmail -t -oi -oem");

    Now about your code, if you change the if to a return you should receive the result from the $msg->send() in exit (&main(@ARGV) ? 0 : -1);.

    --
    if ( 1 ) { $postman->ring() for (1..2); }