Articles in this section

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

Plesk for Windows kb: how-to Plesk for Linux ABT: Group A

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

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

CONFIG_TEXT: <?php
$to = "someuser@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: testuser@example.com' . "\r\n";
$headers .= 'Return-Path: testuser@example.com' . "\r\n";
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:

    CONFIG_TEXT: 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:

    CONFIG_TEXT: sendmail_from = jdoe@example.com

Was this article helpful?

Comments

1 comment
Date Votes
  • Hello,
    $headers .= 'Return-Path: testuser@example.com' . "\r\n"; don't works.
    If we try to use another domain in the filed Return-Path (because we need to do this), Plesk server replace it with the value of the FROM.
    We need to understand this behaviour.
    Thx.

    0

Please sign in to leave a comment.