- Plesk for Linux
What is the return path / sender in PHP mail() scripts?
How to change it?
By default, the system user assigned to the domain that is executing it is used.
The return path would be email@example.com for the following:
User assigned: testuser
For a particular script:
If a different email address is wanted to be the return path and/or sender, it can be customized in the headers, for example:
$to = "firstname.lastname@example.org";
$subject = "Test email";
$txt = "Hello world!";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: email@example.com' . "\r\n";
$headers .= 'Return-Path: firstname.lastname@example.org' . "\r\n";
mail($to,$subject,$txt,$headers, "-f email@example.com");
For all scripts of domain:
Go to Domains > example.com > PHP Settings > Additional directives and add a directive like the following:
CONFIG_TEXT: sendmail_path = "/usr/sbin/sendmail -t -i -f firstname.lastname@example.org"