Search code examples
phpemailphpmailer

Masking 'Reply-To' address header in PHP mail()


While sending an e-mail using php mail() function, the 'From' header can get any random e-mail address and/or name we desire. However, the 'Reply-To' header seems to receive only the accurate e-mail address, apparently in order let the receiver reply to a valid address.

I was wondering if there is any possible way to show a random email address on the 'Reply-To' header, while making reply email to send to a different one. Is that possible at all?


Solution

  • Suppose this is our code:

    $subject = "Your subject";
    $message = "$message";
    $headers = 'From: myemail@my_domain.com' . "\r\n" .
        'Reply-To: ' . $email;
    

    Here we can clearly see that the From address is different than reply to address, this is what tells the browser from which address has the mail been sent and where to reply to, but you want to mask the address of reply-to... So tell me this, if we mask the reply-to address to another address, then what will happen?

    The browser will try to reply to the masked address not the real one... So I believe it is not possible to mask the reply-to address... Because the masked address is not ours, and thus we won't get any reply at all..