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

I'm trying to change the "Return-Path" in an email that my server will be sending out. However, doing the following does not work. (Note: this code _does_ work properly, aside from setting the Return-Path.)
$header = "Return-Path: $from\r\nFrom: $from\r\nTo: $recipient\r\nRepl +y-To: $from\r\nSubject: Subject Here"; open (MAIL, "|$mailprog $recipient"); print MAIL $header."\n\n";
This email is being read by another script, and it reads the Return-Path. Thus, the need to forge this header ;) Thanks.

Replies are listed 'Best First'.
Re: Return-Path Email Header Problems
by Dominus (Parson) on Nov 25, 2000 at 05:51 UTC
    As fastolfe said, it depends on your $mailprog. If you are using mail or mailx, you are out of luck. If you are using sendmail or qmail-inject, include the -f sender argument.

    Also see the on-line manual for your mail program, whatever it is.

Re: Return-Path Email Header Problems
by Fastolfe (Vicar) on Nov 25, 2000 at 05:48 UTC
    The "Return-Path" is normally added by the MTA to match the envelope sender, so with many mailers it's significantly more difficult to forge. Unfortunately we'd need more information (such as the $mailprog and/or MTA) in order to help you.
      $mailprog="/usr/sbin/sendmail -t";
      Sorry I didn't deem this important to begin with.