prob send and NET::SMTP

Discussion in 'Perl Misc' started by lyx, Feb 18, 2005.

  1. lyx

    lyx Guest

    Hi
    I need some help
    i'm scripting in PERL on WinXP ( activeperl)
    I try to do à little mailing script that takes email addresses in a txt file
    and then send the same mail one per one to each recipients
    all is ok but if in the txt file one email is wrong (syntaxe ok but not
    existing)
    the script dies
    error output : "SMTP RCPT command failed: <>: Recipient
    address rejected: Domain not found"

    and the next reciptients won't be emailed.

    how could I test an email ( syntaxe test has been done) ?

    here is an extract from the script

    use MIME::Lite;
    use Net::SMTP;
    my $msg = MIME::Lite-> new (
    From =>$exp,
    To =>$dest,
    Subject =>$subj,
    Type =>'multipart/mixed') ;
    $msg -> attach (
    Type =>'text/HTML',
    Data =>$message_html) ;
    MIME::Lite->send('smtp',$my_smtp,Timeout=>60);
    $msg->send;

    thanks a lot for the futur help

    Lyx
    lyx, Feb 18, 2005
    #1
    1. Advertising

  2. "lyx" <> wrote in
    news:42164f6b$0$12440$:

    > Hi
    > I need some help
    > i'm scripting in PERL on WinXP ( activeperl)
    > I try to do à little mailing script that takes email addresses in a
    > txt file and then send the same mail one per one to each recipients
    > all is ok but if in the txt file one email is wrong (syntaxe ok but
    > not existing)
    > the script dies
    > error output : "SMTP RCPT command failed: <>:
    > Recipient address rejected: Domain not found"
    >
    > and the next reciptients won't be emailed.
    >
    > how could I test an email ( syntaxe test has been done) ?
    >
    > here is an extract from the script


    Thank you for providing a precise description of the problem along with
    a concise code example. However, for future posts, please keep in mind
    that posting something which we can just copy & paste into an editor and
    run unmodified is much more useful.

    Anyway, you can wrap the $msg->send in an eval block to catch the
    exception. IMHO, MIME::Lite should return an error code when the message
    cannot be sent, but given the way it behaves, the following might help:

    #! /usr/bin/perl

    use strict;
    use warnings;

    $| = 1;

    use MIME::Lite;

    my $msg = MIME::Lite->new(
    From =>'',
    To =>'',
    Subject =>'Helloooooo, nurse!',
    Data =>"How's it goin', eh?"
    );

    MIME::Lite->send('smtp', 'mail.unur.com', Timeout => 60);

    eval {
    $msg->send;
    };

    $@ and warn "Exception caught: $@\n";

    print "Finished normally\n";

    __END__

    D:\Home\asu1\UseNet\clpmisc> s
    Exception caught: SMTP RCPT command failed:
    relay not permitted

    at D:\Home\asu1\UseNet\clpmisc\s.pl line 20

    Finished normally

    Sinan
    A. Sinan Unur, Feb 18, 2005
    #2
    1. Advertising

  3. lyx

    lyx Guest

    Thank's a lot for your help, I'm learning perl on my own
    and you realy helped me

    LYX

    ----- Original Message -----
    From: "A. Sinan Unur" <>
    Newsgroups: comp.lang.perl.misc
    Sent: Friday, February 18, 2005 11:47 PM
    Subject: Re: prob send and NET::SMTP


    > "lyx" <> wrote in
    > news:42164f6b$0$12440$:
    >
    >> Hi
    >> I need some help
    >> i'm scripting in PERL on WinXP ( activeperl)
    >> I try to do à little mailing script that takes email addresses in a
    >> txt file and then send the same mail one per one to each recipients
    >> all is ok but if in the txt file one email is wrong (syntaxe ok but
    >> not existing)
    >> the script dies
    >> error output : "SMTP RCPT command failed: <>:
    >> Recipient address rejected: Domain not found"
    >>
    >> and the next reciptients won't be emailed.
    >>
    >> how could I test an email ( syntaxe test has been done) ?
    >>
    >> here is an extract from the script

    >
    > Thank you for providing a precise description of the problem along with
    > a concise code example. However, for future posts, please keep in mind
    > that posting something which we can just copy & paste into an editor and
    > run unmodified is much more useful.
    >
    > Anyway, you can wrap the $msg->send in an eval block to catch the
    > exception. IMHO, MIME::Lite should return an error code when the message
    > cannot be sent, but given the way it behaves, the following might help:
    lyx, Feb 19, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    1,050
    Roedy Green
    Jan 24, 2006
  2. Alex Hunsley
    Replies:
    4
    Views:
    3,410
    Tim Williams (gmail)
    Jun 29, 2004
  3. Raaijmakers, Vincent \(GE Infrastructure\)

    RE: sending of mail (smtp) - connection refused - but smtp serveris running!

    Raaijmakers, Vincent \(GE Infrastructure\), Jun 29, 2004, in forum: Python
    Replies:
    0
    Views:
    864
    Raaijmakers, Vincent \(GE Infrastructure\)
    Jun 29, 2004
  4. Copelandia Cyanescens

    smtplib.SMTP "no attributes SMTP"

    Copelandia Cyanescens, Jul 31, 2004, in forum: Python
    Replies:
    2
    Views:
    1,386
    Copelandia Cyanescens
    Jul 31, 2004
  5. tshad
    Replies:
    1
    Views:
    878
    bruce barker
    May 5, 2008
Loading...

Share This Page