Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Jan 2005
    Posts
    20

    Default How do I set the Return-Path, etc mail headers via PHP?

    Hi all,

    We have a php function that sends an email:
    function send_mail($to, $fromemail, $fromname, $bounce_email, $message, $subject) {
    // To send HTML mail, the Content-type header must be set
    for($i=0;$i<count($to);$i++) {
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
    $headers .= "Return-path: <{$bounce_email}>\r\n";
    $headers .= "Errors-To: <$bounce_email>\r\n";
    // Additional headers
    $headers .= "To: {$to[$i][1]} <{$to[$i][0]}>" . "\r\n";
    $headers .= "From: {$fromname} <{$fromemail}>" . "\r\n";
    // Mail it
    mail($to[$i][0], $subject, $message, $headers, "f");
    }
    }


    However, when we use this function, the server changes the "Return-path" header to:
    Return-path: nobody@rootserverurl.com

    We need this email to be "bounce@accountname.com" as defined in: $bounce_email.

    How would we change it from the "nobody" default?

  2. #2
    Member
    Join Date
    Aug 2002
    Posts
    1,120

    Default

    You have to specify this in the fifth parameter of the mail() function:

    PHP Code:
    mail(tosubjectmessageheaders"-fbounce@accountname.com"); 
    See:

    http://us2.php.net/manual/en/function.mail.php

    for more information. Please note that return path is also called the envelope-sender

  3. #3
    Member
    Join Date
    Jan 2005
    Posts
    20

    Default Thanks!

    Your message was the key. It works.

    Thanks so much!

Similar Threads & Tags
Similar threads

  1. Replies: 0
    Last Post: 03-28-2011, 11:01 PM
  2. Return path a email headers
    By Heritz in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 05-20-2007, 10:48 AM
  3. modify Return-Path: with php mail()
    By h2oski in forum cPanel and WHM Discussions
    Replies: 9
    Last Post: 11-21-2003, 05:19 AM
  4. nobody@hostname in php mail() Return-Path
    By moronhead in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 03-21-2002, 02:22 PM
Tags for this Thread
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube