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.

PHP sending mail as "Nobody" (and have done research here ;))

Discussion in 'E-mail Discussions' started by mooi, May 3, 2005.

  1. mooi

    mooi Member

    Joined:
    Apr 27, 2005
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I'm using:
    WHM 10.1.0 cPanel 10.2.0-R10
    RedHat Enterprise 3 i686 - WHM X v3.1.0

    Done my research here and found this:
    http://forums.cpanel.net/showthread.php?t=31615

    Implemented the suggestions to no avail. Mail is still showing "Nobody" in the "From" field. My email script is:

    ...part of the header declaration....

    $headers .= "From: \"$fromName\" \n <$fromEmail>\r\n";

    mail($toEmail, $subject, $message, $headers, "-f$fromEmail");

    My return path is set correctly, the "fromEmail" is set correctly. Only thing not working is the display name in the "From" field".

    Thus my mails arrive looking like this:
    From: Nobody <my-real-email-address >

    Any help would be greatly appreciated. Am racking my brains out....
     
  2. BenThomas

    BenThomas Well-Known Member

    Joined:
    Feb 12, 2004
    Messages:
    598
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Houston, Texas USA
    cPanel Access Level:
    Root Administrator
    Make sure that you are using phpsuexec. Make a simple PHP script that prints out the process's effective UID and run it through a web browser to be sure.
     
  3. mooi

    mooi Member

    Joined:
    Apr 27, 2005
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for the tip but was afraid to try phpsuexec due to the possibility of extensive code changes. Reversed my previous changes back to the default exim config file that came with cPanel. Did leave in "untrusted_set_sender=*" though.

    Anyways, went back and rechecked the code and looked at the resultant mail and notice that part of the headers specified in my code shows up in the email body.

    Turns out it was the line feeds in the code itself - I had too many. *argh* I learnt my mistake - I never thought it could be this because the code works on our test servers. But am glad to have learnt something today. :P

    This is how my code looked before:

    $headers .= "To: \"$toName\" \n <$toEmail>\r\n\n\n";
    $headers .= "From: \"$fromName\" \n <$fromEmail>\r\n";

    And this is how it looks now:

    $headers .= "To: \"$toName\" <$toEmail>\n";
    $headers .= "From: \"$fromName\" <$fromEmail>\n";

    Why did I have so many line feeds in there before....erm, directly copied the script from a colleague and never questioned the reason. ;) Hope this helps someone out there.
     
Loading...

Share This Page