Re: Trap MX-server responses

Mark Overmeer <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Jan Stapel/Vito & Associates, Inc ([email protected]) [040312 04:00]:

> $sender = Mail::Transport->new(hostname => '10.0.0.61', port => '25', via 
> => 'SMTP', helo =>'vitoassoc.com',
> smtp_debug => 'true');

That may be possible, but certainly not the way I would like people
to use MailBox.  The interface I designed would be either:

   $msg->send(via => 'SMTP');  # creates a Mail::Transport::SMTP each time

or

   my $smtp = Mail::Transport::SMTP->new;
   $smtp->send($msg);

> As I understand Net::SMTP is used by Mail::Transport......via =>'SMTP'.

Correct

> Below is a small script using Net::SMTP, where it looks for "550" return 
> codes to flag bad email address.
>      $smtp->mail('[email protected]');
>      $smtp->recipient('[email protected]');
>          if ($smtp->code() eq "550")
>          {
>           $smtp->reset();
>            $smtp->quit;
> 
> How can I incorporate this same idea in Mail::Transport?

$smtp->send($msg) makes repeated calles to to try_send, in this case
Mail::Transport::SMTP::try_send().  If you want to have more control
over the process, you can use trySend directly:

   my $smtp = Mail::Transport::SMTP->new;
   if($smtp->trySend(...)) .... success

However... when you call it in LIST context, you will also see the
error codes:

   my ($success, $errorcode, $errortext, $errorlocation, $quitsuccess)
      = $smtp->trySend(...);

   if( $errocode==550)
   ...

So: the whole Net::SMTP thing is hidden.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.