http://qs321.pair.com?node_id=100292


in reply to sent mail by perl

First, the SMTP RFC is 821. You can view that here.

Next, if you look on page 20 of that specification, it gives you the information on the RCPT command. There are 2 possible responses for an unknown user.
1) Relay: Essentially, to do what you want would require you to put yourself into the "FROM" header of the e-mail. You will get the corresponding e-mail back.
2) Error Code 550: The mail server could reply with an error code 550, "user unknown". In this case, you could write a program to recieve the error code and abort/notify/bounceback/whatever. Sendmail will give this error as "550: negative permanent filesystem." So, you could use sendmail's output to trigger this error.

Of course, your program should do both so as to account for both.

Just a bit of trivia here: Some sysadmins track this error as a means of detecting potential spammers... Also, some spammers/blackhats track this error as a means of finding valid users to spam/exploit.

Just Another Perl Backpacker