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:
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");
?>
-
Go to Domains > example.com > PHP Settings > Additional directives
-
Add a directive like the following:
CONFIG_TEXT: sendmail_path = "/usr/sbin/sendmail -t -i -f jdoe@example.com"
-
Go to Tools & Settings > PHP Settings > PHP x.x > php.ini
-
Change the
sendmail_from
parameter to required mailbox:CONFIG_TEXT: sendmail_from = jdoe@example.com
Comments
1 comment
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.
Please sign in to leave a comment.