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

Follow

Comments

2 comments

  • Avatar
    Mike K (Edited )

    I am using Plesk 12.5 with qmail.

    Plesk's habit of setting the Return-Path address to the Plesk customer addres, rather than just leaving it the same as From address, breaks DMARC checks.

    changing sendmail_from or sendmail_path in php.ini, using the 4th parameter in php mail() does not work.  Banged my head on this for quite some time by listening to articles like this from Plesk.

    Plesk still overrides the Return Path

    Here is a solution to remove Plesk's setting of the Return Path completely and let the Return Path = From email address.

    # cd /var/qmail/bin

    # cp sendmail sendmail-plesk

    # vi sendmail-modified
    [PHP]
    #!/bin/bash
    sendmail="/var/qmail/bin/sendmail-plesk"
    newargs=""
    flag=0

    # loop through command line arguements
    for var in "$@"
    do
      # if the flag is set
      if [ $flag = 1 ]
      then
        # don't add the from email address
        flag=0
        continue
      fi
      # if we find a -f tag that sets Return-Path
      if [ $var = "-f" ]
      then
        # don't add the -f parameter
        flag=1
        continue
      fi
      # if we got here, its a command line parameter we don't want to skip
      newargs="$newargs $var"
    done

    # send the stdin and new args to sendmail-plesk
    cat | $sendmail $newargs

    [/PHP]

    # chmod 750 sendmail-modified

    # chown root.qmail sendmail-modified

    # rm sendmail

    # ln -s sendmail-modified sendmail

  • Avatar
    Alexandr Redikultsev

    Hello, Mike K!

    Thank you very much for your continuous efforts!

    We really appreciate you sharing the knowledge with us.

Please sign in to leave a comment.

Have more questions? Submit a request