How do I tell sendmail where to send bounced mail?

J

John

I am using the following code to send email from a Perl script:

open(MAIL,"|/usr/sbin/sendmail -t") || return 0;
select (MAIL);
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 "\n";
print "It works!\n";
close(MAIL);
select (STDOUT);


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?
 
S

scooter

You need to set the value of "Reply-to" to either a vaild address or
"(e-mail address removed)" etc.

hth, Abhinav.
 
J

John

scooter said:
You need to set the value of "Reply-to" to either a vaild address or
"(e-mail address removed)" etc.

hth, Abhinav.


I did that with no help :(

Looking at return path of mails with valid recipient I notice that the "Reply-to"
is something that the ISP has and not what I use when sending the email. Could it
be that the ISP changes the headers?
 
E

Eric Pozharski

John said:
I am using the following code to send email from a Perl script:

use strict;
use warnings;
open(MAIL,"|/usr/sbin/sendmail -t") || return 0;

B<die> (or B<croak>) if B<open> fails said:
select (MAIL);
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 "\n";
print "It works!\n";
close(MAIL);

you are supposed to B<die> if B<close> said:
select (STDOUT);

and if it's said:
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?

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.
 
G

Gunnar Hjalmarsson

John said:
I am using the following code to send email from a Perl script:

open(MAIL,"|/usr/sbin/sendmail -t") || return 0;
select (MAIL);
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 "\n";
print "It works!\n";
close(MAIL);
select (STDOUT);

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.

Use the -f option:

open (MAIL, "|/usr/sbin/sendmail -t -fme\@mybiz.biz") ...
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top