SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP mail() problem under PHPSUEXEC

    Hi,

    PHPSUEXEC was recently enabled on our server. Now the mail() function doesn't work anymore cause it identify itself as 'Nobody' and 'Nobody' is not permitted to send mail.

    How do i prevent my script from executing itself as 'Nobody'?
    I know i probably have to change the the owner/group of the script an in order to change the owner/group you need super admin permission...But i don't know how to do it.

    Please give me a clear example of what i have to do. Telling me that i have to chown or chgrp a file doesn't tell me how to do it.

    Thanks a lot!

    Builder

  2. #2
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't tell you how to change the owner or group, but this may help you circumvent the problem by talking directly to the SMTP server instead of using mail():

    PHP Code:
    function SendMail($to "",$subject "",$message "",$headers="",$extra="") {
     if ((
    $fd = @popen(SENDMAIL_PATH " -t " .$extra,'w')) === false) return false;
     
    fputs($fd,"To: " $to "\n");
     
    fputs($fd,"Subject: " $subject "\n");
     
    fputs($fd,"X-Mailer: PHP 5\n");
     if (
    $headers) {
      
    fputs($fd,$headers "\n");
     }
     
    fputs($fd,"\n");
     
    fputs($fd,$message);
     
    pclose($fd);
     return 
    true;
    // end function SendMail 
    Change SENDMAIL_PATH to the path to the sendmail executable, e.g. usr/sbin/sendmail

    Credit to scott at criticalpath dot com, who posted the code in the user comments on mail() in the PHP manual. I recommend downloading the CHM version of the manual and keeping it open while you're coding. You can learn some impressive tricks that way.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, i'll try it right away!


Bookmarks

Posting Permissions

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