Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    72

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

    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 Code:
     $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. #2
    Member
    Join Date
    May 2004
    Location
    USA
    Posts
    406
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    It's probably something added to track abuse.

  3. #3
    Member
    Join Date
    Aug 2002
    Posts
    1,118

    Default

    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. #4
    Member nyjimbo's Avatar
    Join Date
    Jan 2003
    Location
    New York
    Posts
    1,082

    Default

    Quote Originally Posted by doni49 View Post
    When the email message arrives, it has a "sender header" that shows cpUsername@servername.hostdomain.com.
    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.
    "A dog has raised it’s hind leg on the age of nevermore !"
    -- Rolf

  5. #5
    Member
    Join Date
    Oct 2006
    Posts
    72

    Default

    Quote Originally Posted by sparek-3 View Post
    I think you are referring to the envelope-from sender.
    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.

    Quote Originally Posted by sparek-3 View Post
    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.
    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.

Similar Threads & Tags
Similar threads

  1. Problem: Mailman and WHM's "limit mail sends per hour"
    By nothsa in forum cPanel and WHM Discussions
    Replies: 30
    Last Post: 02-14-2011, 07:45 AM
  2. Email in Cpanel sends to address as "local"
    By dragyth in forum E-mail Discussions
    Replies: 1
    Last Post: 11-18-2010, 06:57 PM
  3. Replies: 11
    Last Post: 06-11-2009, 08:15 AM
  4. Default address in horde giving "no valid sender in header" error
    By noimad1 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 05-10-2008, 02:43 AM
  5. Mail forwarders don't work when "Sender Verification" is enabled
    By NovemberRain in forum E-mail Discussions
    Replies: 0
    Last Post: 01-03-2008, 05:11 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube