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 script sends email as Nobody

Discussion in 'E-mail Discussions' started by lemonsensation, Nov 7, 2004.

  1. lemonsensation

    Joined:
    Oct 16, 2004
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I am having problems PHP scripts. When the php script tries to send out an email, it sends the email as "nobody@MYHOSTNAME.com" when the web address and MYHOSTNAME are totally different. So to solve this problem, I turn on "Prevent the user 'nobody' from sending out mail to remote addresses (php and cgi scripts generally run as nobody if you are not using phpsuexec and suexec respectively.)"

    After doing that, emails get stuck in the Mail Queue of the server. It says the email it was trying to send to has an "unrouteable mail domain".

    I tried the PHPsuexec and it fixed the problem. However, I would like to keep phpsuexec off, if possible.

    Bascially the "Return-path:" and "Received:" says it's from "nobody@myhostname.com" . Is there a way to fix this? I am reading and it seems to be a limitation of PHP, but there must be a solution because I've used other hosts without phpsuexec and I was able to send out mail with PHP.
     
  2. ckh

    ckh Well-Known Member

    Joined:
    Dec 6, 2003
    Messages:
    356
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Phoenix, AZ
    cPanel Access Level:
    DataCenter Provider
    I do something like:

    $return="returnaddress@somewhere.com";
    $email="SendToSomeone@hisdomain.com";
    $subject="blah blah blah";
    $body="more blah blah blah";

    mail("$email", $subject, $body, "FROM: $returnemail","-f$returnemail");


    This makes the 'return path' & 'from' to contain the email address returnaddress@somewhere.com

    I also have:

    trusted_users = nobody
    untrusted_set_sender = *

    in the first box of the exim configuration editor.....

    Chris
     
  3. lemonsensation

    Joined:
    Oct 16, 2004
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    hm... I'm trying out the

    trusted_users = nobody
    untrusted_set_sender = *

    in the exim conf. editor, but it doesn't seem to work. The php script is still trying to send out the mail using "nobody@myhostname.com", so the email is not being sent and it's going into my Mail Queue.

    I forgot the say that this is not a custom PHP script, so i can't try out that code in PHP. I'm using Drupal which is a CMS. I am pretty sure Drupal is configured correctly. I would imagine this is not Drupal's fault but it is that I have not configured something properly.
     
  4. ccccanada

    ccccanada Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    279
    Likes Received:
    0
    Trophy Points:
    16
    as long as you have the setting
    checked in WHM the server will not send emails from the user nobody.
     
  5. lemonsensation

    Joined:
    Oct 16, 2004
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    ccccanada: I had the whole concept of PHP mail sending out as 'nobody' and phpsuexec mixed up in my head and I was expecting it to do something that it can't. Thanks for clearing it up. :)
     
  6. ccccanada

    ccccanada Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    279
    Likes Received:
    0
    Trophy Points:
    16
    No problem at all.

    By looking at your post it finaly made me search for this problem and found the other post which had the solution so it helped me as well.
     
Loading...

Share This Page