Results 1 to 10 of 10

Thread: How to check for mail function used in PHP scripts?

  1. #1
    Member
    Join Date
    Nov 2002
    Posts
    430

    Default How to check for mail function used in PHP scripts?

    Could someone please tell me the command to find out which scripts/accounts uses the mail command in PHP (SSH).

    Also, once located is it somehow possible to find out if a user spammes with mail() as it uses user nobody?

    Thanks
    John

    cPanel.net Support Ticket Number:

  2. #2
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Jun 2003
    Posts
    647

    Default

    We have been researching to find a way to control the use of php mail() more too, as spam is getting worse and worse.

    cPanel.net Support Ticket Number:

  3. #3
    Member
    Join Date
    Jan 2003
    Location
    Herts, UK
    Posts
    100

    Default

    Hi,

    You could always re-write the source code of the mail function to create a log. I can't think of any other way of doing it, unless you just disable the mail() function and make people use fsockopen for SMTP.


    Rob

    cPanel.net Support Ticket Number:

  4. #4
    Member
    Join Date
    Jan 2002
    Location
    UK
    Posts
    248

    Default

    in your php.ini set

    disable_functions = mail

    .. which will stop the function being used.

    or turn off user 'nobody' sending mail in the cpanel tweak settings (ofcourse this wont work if you use phpsuexec or cgi suexec).

    cPanel.net Support Ticket Number:

  5. #5
    Member
    Join Date
    Nov 2002
    Posts
    430

    Default

    Thanks for your responses. So it can be turned of in the ini file. I'm not sure, however, that would be a good idea. Lots of clients are using it and I would probably loose quite some customer - anyway, thanks for the tip. Maybe I'll use it some time.

    John

    cPanel.net Support Ticket Number:

  6. #6
    Member
    Join Date
    Jan 2002
    Location
    UK
    Posts
    248

    Default

    phpsuexec (if you're prepared to run it) at least should allow you to ID which user is sending the mail rather than it all appearing as coming from 'nobody'.

    cPanel.net Support Ticket Number:

  7. #7
    Member
    Join Date
    May 2003
    Posts
    36

    Default php mail()

    The best solution would be to change php.ini, so instead of calling sendmail (exim) directly, php calls a wrapper function, which adds the Apache environment to the headers of the message that gets sent, including the avctual path to the php script, the website ServerName, etc, (and optionally logs, if one needs that too) and then passes the message to the MTA

    Ive done this before, but the php setup on the cpanel servers seems to strip out the Apache environment before calling the "sendmail" function, and I havent figured out why.

    cPanel.net Support Ticket Number:

  8. #8
    Member
    Join Date
    Oct 2002
    Posts
    10

    Default

    You can disble the mail function, and compile a CGI version of PHP which you can allow users to use only when they need the mail function.

    cPanel.net Support Ticket Number:

  9. #9
    Member
    Join Date
    May 2003
    Posts
    36

    Default

    I dont want to disable the function.. I just want to insert a wrapper that will add useful headers in the mail that is sent, which would allow me to take those headers, and find the specific script that sent the mail.

    Oh, and it should record the HTTP_REMOTE_ADDRESS in the headers too, so if someone is abusing the site we have a record of who.

    Ive redesigned formmail so it does this, it would be real nice if I could insert a wrapper in between php and its call to 'sendmail', and have access to the Apache HTTP variables so I could do it there too.

    My formmail mod also uses BSMTP rather than the hideous "-t" method but since php doesnt provide envelope information seperately from the headers it'd be a wash there.

    cPanel.net Support Ticket Number:

  10. #10
    cPanel Partner NOC cPanel Partner NOC Badge HostDime's Avatar
    Join Date
    Mar 2003
    Location
    Orlando, Florida
    Posts
    81

    Default

    largolam - I'd be willing to pay you via Paypal if you help me with the code for creating a log.

    cPanel.net Support Ticket Number:

Similar Threads

  1. php mail function?
    By kobeeightjp in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 01-28-2010, 12:36 AM
  2. E-mail not going on same server sites using php mail() function
    By muzaffar in forum E-mail Discussions
    Replies: 1
    Last Post: 06-29-2009, 12:48 PM
  3. PHP scripts not function properly
    By wangtenet in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 10-21-2005, 04:20 AM
  4. PHP and mail() function
    By Jontxu40 in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 06-11-2003, 01:10 PM