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.

Can't get my forms to mail to emails not located on my server.

Discussion in 'E-mail Discussions' started by fireineyes, Sep 20, 2007.

  1. fireineyes

    fireineyes Member

    Joined:
    Sep 2, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Can't get my php forms to mail to emails not located on my server. What would be there reason for this? Some of the failed messages say that the user 'nobody" can't send emails. Is it dangerous to allow user 'nobody' to email? I figure it is. Here is my php code..
    Code:
     
    //$contact is name of person filling out form
    //$em is email address of person filling out form
    $to = "\"$contact\"<$em>";
     
    $headers = "From: \"MYDOMAIN.com\"<myemail@charter.net>";
    
    if (!$em==""){
    mail( "myemail@yahoo.com", "$subject", "$message", "$headers");
    
    mail( "\"Rick\"<myyahooaddress@yahoo.com>,\"Webmaster\"<chris@mydomain.net>", "$subject", "$info", "From: \"$contact\"<$em>");
    
    
    I gathered one email that said this...


    Code:
    This message was created automatically by mail delivery software.
    
    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es)
     failed:
    
      myyahooaddress@yahoo.com
        Mail sent by user nobody being discarded due to sender restrictions
     in WHM->Tweak Settings
    
    ------ This is a copy of the message, including all the headers. ------
    
    Return-path: <nobody@server1.myserver.com>
    Received: from nobody by server1.myserver.com with local (Exim
     4.63)
    	(envelope-from <nobody@server1.myserver.com>)
    	id 1IYW7f-0000Ml-BF; Thu, 20 Sep 2007 19:11:55 -0500
    To: myyahooaddress@yahoo.com
    Subject: Wholesale Sign Builders Application
    From:myemail@charter.net
    To:info@myemail.com
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    Message-Id: <E1IYW7f-0000Ml-BF@server1.myserver.com>
    Sender: Nobody <nobody@server1.myserver.com>
    Date: Thu, 20 Sep 2007 19:11:55 -0500
    
    I just want to be able to mail a form to myemail@charter.net or myemail@yahoo.com off the server. Can anyone give me some pointers?
     
  2. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    You probably have your server set up to disallow sending out mail as the nobody user but then don't have PHP compiled as CGI.

    If PHP is running as an Apache module, this basically means that every message sent out through a PHP script on the server will be send out using an envelope-sender of nobody@yourserversname.com.

    You might alleviate this in the short term by using:

    Code:
    mail( "\"Rick\"<myyahooaddress@yahoo.com>,\"Webmaster\"<chris@mydomain.net>", "$subject", "$info", "From: \"$contact\"<$em>","-f" . $em);
    Which basically forces sendmail to use whatever $em is as the envelope-sender.

    The envelope-sender is the address that a bounce message will go to should there be problems delivering the message. Its probably a good practice to use the -f parameter in a sendmail system.
     
  3. fireineyes

    fireineyes Member

    Joined:
    Sep 2, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    How do I have PHP compiled as CGI?

    So if I approach the long term solution, what do you suggest? I am pretty green at this stuff so bear with me. How do I have PHP compiled as CGI? Any suggestions?
     
  4. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    I'm really not sure any more. I think they have changed the way easyapache works. Used to be you could just run /scripts/easyapache from the command line and select an option with phpsuexec enabled, depending on how much customization you wanted. But I'm not sure if they are using phpsuexec any more and I'm not sure what the new easyapache looks like. Perhaps someone with more knowledge of the recent easyapache changes could provide more help in this area.

    Alternatively you can log into the WHM as root and under Tweak Setting, uncheck the option of prevent nobody from sending out mail. This will allow PHP to send out mail as the nobody user with PHP compiled as an Apache module.
     
  5. fireineyes

    fireineyes Member

    Joined:
    Sep 2, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Is that a dangerous option?

    Is that a dangerous option? Allowing nobody?
     
  6. fireineyes

    fireineyes Member

    Joined:
    Sep 2, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Explain this line..

    This will allow PHP to send out mail as the nobody user with PHP compiled as an Apache module

    Especially the last part stating.. PHP compiled as an Apache module

    Do I go into Easyapache? or do it from WHM?
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Note that /scripts/easyapache and WHM -> Software -> Apache Update are merely different interfaces for the same EasyApache functionality.
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Potentially. If you allow people to send as user nobody and then one of your user's scripts is exploited to send spam, you wont know which user is sending the mail. As a result, it can take a while to track down while your server is spewing spam and being blacklisted as a spam server.

    Having mail sent as the user will mean you can see in the mail queue who is sending mail and if they're sending spam, you know to suspend that user's account and inform them that their script has been exploited and they need to correct that.
     
  9. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    In EA3, phpSuExec support has been dropped entirely in favor of SuPHP. To enable this, when you get to Profile :: Apache :: PHP Main :: PHP Specific :: Basic, ensure Mod SuPHP Build PHP with "CGI" and "Force CGI Redirect" is selected. If you do not see that option, select "Advanced Configuration" to see it and be able to select it.
     
Loading...

Share This Page