prob send and NET::SMTP

L

lyx

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: <[email protected]>: 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
 
A

A. Sinan Unur

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: <[email protected]>:
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 =>'(e-mail address removed)',
To =>'(e-mail address removed)',
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
 
L

lyx

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" <[email protected]>
Newsgroups: comp.lang.perl.misc
Sent: Friday, February 18, 2005 11:47 PM
Subject: Re: prob send and NET::SMTP
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top