Here is the code for add Return-path in php mail programmatically.
$today = date("F j\t\h Y, g:i a");
$name = 'Yourname';
$from = '[email protected]';
$to = '[email protected]';
$cc = '[email protected]';
$bcc = '[email protected]';
$subject = 'Example Subject';
// To send HTML mail
$headers = "MIME-Version: 1.0 \\r\\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1;
format=flowed \\r\\n";
$headers .= "ontent-Transfer-Encoding: 8bit \\r\\n";
$headers .= "X-Mailer: PHP/" . phpversion(). "\\r\\n";
$headers .= "X-Priority: 1 (Highest) \\r\\n";
$headers .= "X-MSMail-Priority: High \\r\\n";
$headers .= "Importance: High \\r\\n";
// Additional headers
$headers .= "From: $name<$from> \\r\\n";
//This is one option to add the return path
$headers .= "Reply-To: $name<$from> \\r\\n";
$headers .= "Return-Path: $from \\r\\n";
$headers .= "Cc: $cc \\r\\n";
//See the 5th argument in mail function for Return-path
mail("toname<$to>",$subject,"This is the test message for How to add return path in the php mail function.",$headers,"-f $from");
OR
add sendmail-path in php.ini file
sendmail_path = sendmail -t -i -F [email protected] -f [email protected]
How to find php.ini file in Linux system
root@localhost:~# find / -name php.ini