http://www.perlmonks.org?node_id=177993

kidd has asked for the wisdom of the Perl Monks concerning the following question:

I usually send my mails trough sendmail and using CGI so I know the basic sintax...

Now what I need is that when I send my mails, whenever a message is not delivered, I need the message to be bounced back, lets say to noreply@domain.com...

I want to know if there is a way to do this, and how can I do it ?

Replies are listed 'Best First'.
(wil) Re: E-Mail Problem
by wil (Priest) on Jun 28, 2002 at 12:38 UTC
    It's not up to Perl or 'CGI' to know what to do if a message is undeliverable. After all, once the message has flied through your method of sending (you don't specify: Perl module? If so, which one?) it's at the hand of the demon handling the sending of your mail.

    So basically, you need to look at the config of your sendmail program on your server and see what this is set to do. You can usually specify a return to address, or to delete bounced messages and you can also specify how long the program should try before giving up.

    The best you can do with your Perl/CGI script is to make sure that you set a correct From: and/or a Reply-To: address in your message headers, so that if the sending process fails your sendmail demon will be able to send you a message explaining why.

    Hope this helps.

    - wil
Re: E-Mail Problem
by bwana147 (Pilgrim) on Jun 28, 2002 at 12:55 UTC

    This is pretty off topic, but you should try and get more information on the Return-Path: header. That's the one that contains the address to bounce back to in case of problem. Now, whether you can set it to your liking and how, or whether it will be overridden by your MTA no matter what you do, that's another story.

    --bwana147

Re: E-Mail Problem
by kodo (Hermit) on Jun 28, 2002 at 12:39 UTC
    Well this ain't a perl-problem really, but usually when using sendmail the mail should be send back to the user that sent it. But that depends on sendmail-configuration, read the man-page or have a look at sendmail.org.

    giant