- 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 firstname.lastname@example.org 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 = "email@example.com";
$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: firstname.lastname@example.org' . "\r\n";
$headers .= 'Return-Path: email@example.com' . "\r\n";
mail($to,$subject,$txt,$headers, "-f firstname.lastname@example.org");
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 email@example.com"