Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
August 1, 2008, 11:42 am
rate this thread
I am using the following code to send email from a Perl script:
open(MAIL,"|/usr/sbin/sendmail -t") || return 0;
print "To: mycustomer\@home.com\n";
print "From: me\@mybiz.biz\n";
print "Return-Path: me\@mybiz.biz\n";
print "Subject: Hello world\n";
print "It works!\n";
The code works just fine provided the From address is OK.
If the address is invalid (but lexically OK) I want to get a "bounced email
receiver is no longer" etc. note but I get nothing.
The Return path does not seem to help.
What should I do to get info what email bounced or were invalid?
Re: How do I tell sendmail where to send bounced mail?
Use 3-arg B<open>, B<die> (or B<croak>) if B<open> fails, include I<$!>
in bye-bye message.
Since you write in I<MAIL>, you are supposed to B<die> if B<close>
fails (it can fail).
Since you write in pipe, you are supposed to check I<$?>, and if it's
not C<0> you are supposed to B<die>.
OK, funny part over. I believe you don't understand the ways mail goes.
If you absolutely insist on using F</usr/sbin/sendmail> (what exactly
hides behind it is important, and no-one, except you, is supposed to
know your setup), then the only way you can go is increasing verbosity,
enabling debug, and parsing its output (note, by-directional pipes are
tricky). And that won't give you much.
I believe, that you are somewhat infamiliar with your setup. Hence a
bit of explanation. What F</usr/sbin/sendmail> does (I think, in most
cases) is putting its input in queue and trigerring queue-runner.
That's all. That's the queue-runner what talks to servers.
If you want server responces, you must talk to server yourself.
B<Net::SMTP> is the closest talker. There are alternatives (CPAN is
your friend, package manager of your distribution is your friend too).
And now funny part is really over. I believe that in most cases (in
case the server will talk to you at all) you will receive C<251> (mail
will be forwarded) or C<252> (mail will be forwarded anyway) codes
(C<RFC2821> is your friend).
So, you'll better say what's your real goal is.
Torvalds' goal for Linux is very simple: World Domination