Plesk

How to specify default Return-Path for PHP mail scripts in Plesk

Question

How to specify the exact default Return-Path for PHP mail() scripts in Plesk?

Answer

By default, Return-Path includes the system user assigned to the domain that is executing the script with the function mail() (i.e. jdoe@example.com for user jdoe on the subscription example.com).

The functionality of changing this setting via Plesk UI is yet to be implemented. You may vote for such a possible feature on the UserVoice portal.
The top-ranked suggestions are likely to be included in the next versions of Plesk.

Some possible workarounds can be applied here:

For a particular script

<?php
$to = "someuser@example.com";
$subject = "Test email";
$txt = "Hello world!";
$headers = "MIME-Version: 1.0" . "rn";
$headers .= "Content-type:text/html;charset=UTF-8" . "rn";
$headers .= 'From: testuser@example.com' . "rn";
$headers .= 'Return-Path: testuser@example.com' . "rn";
mail($to,$subject,$txt,$headers, "-f testuser@example.com");
?>

For all scripts of a domain

  1. Log into Plesk

  2. Go to Domains > example.com > PHP Settings > Additional directives

  3. Add a directive like the following:

    sendmail_path = "/usr/sbin/sendmail -t -i -f jdoe@example.com"

For all domains on one PHP version

  1. Log into Plesk

  2. Go to Tools & Settings > PHP Settings > PHP x.x > php.ini

  3. Change the sendmail_from parameter to required mailbox:

    sendmail_from = jdoe@example.com