when I send a email and the email address (RCPT) is wrong the code dies.
More details please. What do you mean by
"the code dies."
I made an attempt at replicating what you are saying based
on face value. Conisder the following code:
#!/usr/bin/perl -w
$|=1;
use strict;
use MIME::Lite;
my @addrs=qw/ nobody@nowhere.com my_real_mail@myisp.com /;
#
# This is one bogus email address and one good
# email address. The good address has been sanitized
# for this posting.
foreach my $addr(@addrs){
printf "Sending email to %s...",$addr;
my $msg = MIME::Lite -> new (
From => 'my-return@isp.com',
To => $addr,
Subject => 'this is a test',
Type=> 'TEXT',
Data => 'test 1 2 3...'
);
MIME::Lite->send("smtp","localhost",Port=>9925);
$msg->send;
printf "Message sent.\n";
}
In my test I used one real address, and one bogus address.
The loop sends to the bogus address first. It runs, no
errors, no problems.
OK... so I modified it and ran it again.
#!/usr/bin/perl -w
$|=1;
use strict;
use MIME::Lite;
my @addrs=qw/ nobody@nowhere.com me@my-isp.net /;
my $msg = MIME::Lite -> new (
From => 'me@my-isp.ne',
To => join(",",@addrs),
Subject => 'this is a test',
Type=> 'TEXT',
Data => 'test 1 2 3...'
);
MIME::Lite->send("smtp","localhost",Port=>9925);
$msg->send;
printf "Message sent.\n";
and this ran without problems.
Now, in both cases the SMTP server complained to me that
the address was bogus, but the mail still went to the
legit address...
So, now I'm confused. What kind of errors are you seeing?
Before you think there is some sort of magic foo involved
with the line
MIME::Lite->send("smtp","localhost",Port=>9925);
there isn't. This is there because my laptop does not
send mail through its native sendmail instance but
instead uses an SSH tunnel to send email through my main
server at home. Makes configuration of my laptop easier! :-)
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
|