The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cPanel Shared Hosting Acct - PHP script sends mail, "sender" header says....

Discussion in 'E-mail Discussions' started by doni49, Mar 20, 2008.

  1. doni49

    doni49 Well-Known Member

    Joined:
    Oct 4, 2006
    Messages:
    74
    Likes Received:
    0
    Trophy Points:
    6
    I have a shared hosting account on a server running cPanel. I've got a PHP script that sends mail using the mail function.

    When the email message arrives, it has a "sender header" that shows cpUsername@servername.hostdomain.com.

    PHP:
     $to="MyName<scalahosting@MyDomain.com>";
      
    $headers "From:  MyName<myemail@MyDomain.com>\r\n";


      
    //I added this line to try and FORCE it to use the proper name/address
      //but I STILL get "Sender:  <cpUsername@servername.hostdomain.com>" in the headers.
      
    $headers .= "Sender:  MyName<myhemail@MyDomain.com>";


      
    $headers . = "To: recipient<recipient@MyDomain.com>"
      
    mail  ($to,$subject,$msgBody,$headers);
    I just moved from a different host a little more than a month ago and this didn't happen on the old host's server. The new host can't find any reason for it. I thought maybe there was some obscure setting.
     
  2. jandafields

    jandafields Well-Known Member

    Joined:
    May 6, 2004
    Messages:
    426
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    It's probably something added to track abuse.
     
  3. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    I think you are referring to the envelope-from sender.

    There's basically four parts used when an e-mail transaction happens.

    The first part is the HELO or EHLO which is just an introduction that the sending server issues to the receiving server.

    The next part is the MAIL FROM address. This is the envelope sender.

    The next part is the MAIL TO address. This is who the address is being sent to. Also called the envelope-to.

    The final part is the DATA part, where headers and the message itself is constructed.

    Using the PHP mail() function, it accepts 5 parameters. (http://us.php.net/manual/en/function.mail.php)

    The first parameter, the to address is basically setting the MAIL TO address.

    The second and third parameters set the subject and message parts of the message. The subject is part of the header information so it is given after the DATA part. The message is also given after the DATA part.

    The fourth parameter just sets any additional headers, which again are given after the DATA part.

    As you can see no envelope sender (MAIL FROM) address has been given yet. This can usually be defined with the fifth parameter, depending on what MTA you are using. Since all cPanel servers use exim as its MTA, you can define an envelope-sender for a message with:

    "-fanother@address.com"

    where another@address.com is the defined envelope-sender.

    The envelope sender is the e-mail address that bounce messages will go to. If you send a message out through a PHP script, and the mail server is unable to deliver that message to the intended recipient, then it will bounce back to this envelope sender. Mail servers themselves do not see anything that are in the headers, header information is generally only viewed by the e-mail client after the user receives the message.

    As far as a receiving server is concerned it will see that a message was sent to the envelope-to from envelope-sender. So even if you set a From header using the fourth parameter of the PHP mail() function, the actual mail server is not going to know this value.
     
  4. nyjimbo

    nyjimbo Well-Known Member

    Joined:
    Jan 25, 2003
    Messages:
    1,125
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    New York
    I'm pretty sure this is a configurable option in the hosts WHM control panel for "Exim Configuration Editor" they set it on or off to help track mail abuse. Contact your hosting
    provide and mention this and they should be able to tell you if its on or off. I dont think you can eliminate it as its added by the MTA.
     
  5. doni49

    doni49 Well-Known Member

    Joined:
    Oct 4, 2006
    Messages:
    74
    Likes Received:
    0
    Trophy Points:
    6
    Actually just like there's a header labled From and (usually) To, there's one labled "Sender". When the message is viewed in Thunderbird, this sender header is actually shown right along with the Subject and Sender. I don't like this. I have no problem with it as long as it's a header that no normal mail client shows.

    I tried setting this "envelope sender" to my address as well. That didn't produce any change.

    I also tried specifically adding this sender header to my message but with my email address. NO change there either.
     
Loading...

Share This Page