Results 1 to 9 of 9
  1. #1

    PHP and sending mail as nobody

    I currently have "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.)" checked. So my question is, how can I write a form in PHP so it doesnt run as nobody and the email will get sent out? Currently I am running into a problem where email is being sent out from the form to the domains that are on the server, but not to domains that arent hosted, i.e. cox.net, hotmail.com, yahoo.com, etc, etc.

    Thanks!

  2. #2
    Join Date
    Oct 2001
    Location
    Mountain Home Arkansas
    Posts
    131
    here's a pasting from a user contribution at php.net that I found helpful



    The most common problem people have with the mail() function is the failure to include an additional header containing the from address in the call (along with the standard from address). This commonly results in failed delivery due to spam filtering at the receiving end. The solution: set your header-from address, or use this function:

    <?
    function MAIL_NVLP($fromname, $fromaddress, $toname, $toaddress, $subject, $message)
    {
    // Copyright � 2005 ECRIA LLC, http://www.ECRIA.com
    // Please use or modify for any purpose but leave this notice unchanged.
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "X-MSMail-Priority: Normal\n";
    $headers .= "X-Mailer: php\n";
    $headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
    return mail($toaddress, $subject, $message, $headers);
    }
    ?>
    rocket science is more fun when you accually have rockets!

  3. #3
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738
    Adrnalnrsh,

    In order for you to do this you must install phpsuexec (in cpanel when you build apache it can be auto installed)

    phpsuexec will run all php scripts as the users account rather than 'nobody'.

    You may need to install this if you're going to prevent 'nobody' from sending.

    The downside is, phpsuexec will give an error if you're running any scipts with chmod 777. You can see where it can be a pain.

    Hope this helps
    <<< Please see Forum Guidelines for signature setup. >>>

  4. #4
    I've done this before without phpsuexec, using the method above, this current script that I am using doesnt use that method above, which is the problem. Anyhow, I can't or shouldnt use phpsuexec because I am running WHMAutopilot on this server.

  5. #5
    Join Date
    Apr 2004
    Location
    Chicago
    Posts
    163
    Just set a correct Return-Path in mail headers

  6. #6
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738
    You can also do a search on sending mail via SMTP in PHP.

    That will solve your problem.

    Cheers.
    <<< Please see Forum Guidelines for signature setup. >>>

  7. #7
    Join Date
    Jul 2005
    Location
    fremont, CA
    Posts
    8
    this worked for me:

    mail($email, $subject, $message, $from_address, "-f $from_address");

  8. #8
    Originally posted by skolar
    this worked for me:

    mail($email, $subject, $message, $from_address, "-f $from_address");
    Where do I put this? Any text program?

  9. #9
    Join Date
    Jul 2005
    Location
    fremont, CA
    Posts
    8
    in your php script where you want to use the mail() function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •