Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: getting SMTP failure codes

by chuckbutler (Prior)
on Feb 05, 2010 at 01:42 UTC ( #821486=note: print w/replies, xml ) Need Help??


in reply to Re: getting SMTP failure codes
in thread getting SMTP failure codes

My only improvement would be to loop on the call to 'recipient( )' and capture the results yourself. Please see below. 'recipient( )' does this internally, anyway. Good luck. -c

#test_mail.pl use Net::SMTP; use Net::Cmd; $smtp = Net::SMTP->new( Host => '192.168.55.173', Debug => 1, ); die "Did not connect to host..." unless defined($smtp); #you can remo +ve this, so it would die w/ your address $smtp -> mail("root\@test-server.my.home"); @good = (); @bad = (); @mess = (); foreach $toadr (('good_address@my.home','bad_address@my.home')) { if ($smtp -> recipient( $toadr,{ SkipBad => 0, Notify => ['FAILURE +']})) {; #make result boolean, 1 ::= good push( @good, $toadr ); } else { push( @bad, $toadr ); push( @mess, $smtp->message() ); } } $smtp -> data(); $smtp -> datasend("TO: good_address@my.home\n"); $smtp -> datasend("TO: bad_address@my.home\n"); $smtp -> datasend("SUBJECT: Test e-mail from root\n"); $smtp -> datasend("\n"); $smtp -> datasend("A test message.\n"); $smtp -> dataend(); print "These address(es) went: @good\n"; print "These address(es) were bad \[ and why \]:\n"; for (0..$#bad) { print "$bad[$_] \[ $mess[$_] \]\n"; } $smtp -> quit();

Replies are listed 'Best First'.
Re^3: getting SMTP failure codes
by e5z8652 (Novice) on Feb 05, 2010 at 18:07 UTC

    For some reason I was thinking that if I looped on them that it would take longer. But I timed it and the results are about the same (at least on my network & mail server). If recipient() is doing the same thing, then of course it wouldn't matter. (And I should have been able to figure that out from the debug output anyway!)

    So populating an array with the addresses, and then running a foreach loop on the array of addresses would get me where I want to go.

    Thanks for the clue!

      How do i run this script on a root, i mean what command to use
      How do i run this script on a root ?
      #test_mail.pl use Net::SMTP; $smtp = Net::SMTP->new( Host => '192.168.55.173', Debug => 1, ); $smtp -> mail("root\@test-server.my.home"); @good = $smtp -> recipient('good_address@my.home','bad_address@my.home +',{ SkipBad => 1, Notify => ['FAILURE']}); $smtp -> data(); $smtp -> datasend("TO: good_address@my.home\n"); $smtp -> datasend("TO: bad_address@my.home\n"); $smtp -> datasend("SUBJECT: Test e-mail from root\n"); $smtp -> datasend("\n"); $smtp -> datasend("A test message.\n"); $smtp -> dataend(); print "These addresses went: @good\n"; $smtp -> quit();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821486]
help
Chatterbox?
[Corion]: Mhhmmm - https://sod.pixlab .io/ looks really interesting for embedding with Perl (XS), but they don't have any kind of free model available and the cheapest pretrained model costs EUR 40 :-(
[Corion]: Maybe I should mail them to find out if they can provide me a "hotdog / no hotdog" model for developping the XS bindings. It would be nice to have a self-contained XS library for applying models to data. Or maybe I should look at TensorFlow, which can...
[Corion]: ... at least be trained by me, instead of relying on a vendor
[Discipulus]: complex and interesting
[Corion]: Discipulus: My hope would be that you can install the module from CPAN, download a model, and get image descriptions/ object detection within half a day, which would be great :)

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2018-06-18 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (109 votes). Check out past polls.

    Notices?