in reply to Re: Mail::Sender error
in thread Mail::Sender error

updateI just perused the source of Mail::Sender and noticed that an exit value of 40 is SERVNOTAVAIL (and it closes the socket which explains the rest of your error messages). Moral: check for errors and act appropriately.

I'm sorry, can you explain that?

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Re: Re: Mail::Sender error
by derby (Abbot) on Aug 15, 2002 at 19:27 UTC
    Sure, in a nutshell, there's an issue with the mail server and its not available (SERVNOTAVAIL). Mail::Sender is noticing the unavailabilty, setting an error code, and then closing the socket to the server.

    At its heart Mail::Sender uses SMTP. The protocol is quite simplistic (hence the S) and returns a code with each reply.

    The author has decided to reduce the myriad of 4xx and 5xx STMP error replies to a single SERVNOTAVAIL message. In addition, if for some reason he cannot read from the socket (lost connection, crashed machine), he flags that as SERVNOTAVAIL too.

    This is one of the disadvantages of using SMTP directly as opposed to an MTA (mail transfer agent) like sendmail. If you drop an email into an MTA, it may try to send the email several times for you. When using STMP directly, you have to decide what to do (drop them to the floor, queue them up for another go-round, etc).

    -derby

      Found it. Turns out an earlier regex was not capturing the to email address properly. Without the correct address the smtp server would baulk.

      Thanks for your help

      Neil Watson
      watson-wilson.ca

Re: Re: Re: Mail::Sender error
by vek (Prior) on Aug 15, 2002 at 19:35 UTC
    Mail::Sender is generating an error message because it could not connect to the server. Because you are not checking for errors, you would never know that and your code continues anyway. A quick perusal of the Mail::Sender doc suggests some error checking techniques. Something to the effect of:
    $sender->Open({ smtp =>'mail', to =>"$from", from =>"$ticketad", fake_from =>"$ticketad", subject =>"Help Desk Submission", headers => "Errors-To: postmaster\@mydomain.com"}); die "Error: $Mail::Sender::Error\n" unless ref $sender;
    -- vek --