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 mail() and bandwidth logging

Discussion in 'E-mail Discussions' started by gatewayza, Nov 4, 2009.

  1. gatewayza

    gatewayza Registered

    Nov 4, 2009
    Likes Received:
    Trophy Points:
    Hello folks,

    I am moving from ensim to cpanel. I have my server up and running and I am moving the sites to cpanel. I have a couple of website that use PHP mail() to send out email and I need to be sure that this bandwidth is counted.

    What settings to I need to enable/change to be sure that this is done?

  2. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Nov 5, 2008
    Likes Received:
    Trophy Points:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    All mail that is sent out using your local Exim mail sever is tracked for bandwidth usage; sent e-mails could be verified by checking the server's Exim logs (in "/var/log/"). Additionally, any bandwidth transfer used (via HTTP) from users loading the PHP-based web site is also tracked through the domain logs from Apache.

    To help reduce the likelihood of hosted scripts bypassing the local mail server (i.e., by a script connecting to an external or third-party mail server to send via SMTP) I recommend using the following option available via the Security Center in WHM:
    Menu path in WHM: Main >> Security >> Security Center >> SMTP Tweak
    * Enabling the SMTP Tweak option will help to limit the ability of malicious scripts from connecting out to third-party/external/unknown mail servers.

    I recommend ensuring that you have both SuPHP and SuExec enabled so that users PHP scripts are executed as the user (that owns the virtual host) instead of as the shared Apache user/group "nobody".

    SuPHP can be enabled at the following menu path via WHM:
    WHM: Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration
    * Here you can switch the PHP handler to SuPHP and ensure SuExec is enabled. If SuPHP is not listed in the drop-down menus for PHP then you will need to run EasyApache to install support for SuPHP in Apache and PHP.

    For reference, the SuExec and PHP handler options can also be changed via root SSH access; the following commands (1) display the current configuration and then (2) if available, sets the default PHP version to 5, sets PHP 4 handler to none assuming PHP 4 is not installed, sets PHP 5 handler to SuPHP, and enables SuPHP (indicated by a "1" as the last argument in the command):
    # /usr/local/cpanel/bin/rebuild_phpconf --current
    # /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1
    Via SSH, further usage information is displayed when no CLI arguments are entered, as seen below:
    # /usr/local/cpanel/bin/rebuild_phpconf
    Usage: /usr/local/cpanel/bin/rebuild_phpconf [--dryrun] [--no-restart] [--no-htaccess] [--current|--available] <Default PHP> <PHP4 Handler> <PHP5 Handler> <Suexec>
     --dryrun       : Only display the changes that would be made
     --no-restart   : Don't restart Apache after updating the php.conf link
     --no-htaccess  : Don't update user configurable PHP mime mapping.
     --current      : Show current settings
     --available    : Show available handlers and PHP SAPIs
     <Default PHP>  : Version of PHP to set as default handler for .php files
     <PHP# Handler> : Type of Apache module to use in serving PHP requests
     <Suexec>       : enabled, disabled, 1 or 0
    Note: Running EasyApache to install support for SuPHP will not automatically enable SuPHP; to enable SuPHP refer to the above instruction.

    If SuPHP support is needed, EasyApache can be run via your root WHM control panel, or it can be run via root SSH Access, as described below:

    Here is the command to run EasyApache via root SSH access:
    # /scripts/easyapache
    Here is the menu path to run EasyApache via your root WHM control panel:
    WHM: Main >> Software >> EasyApache (Apache Update)

    I personally recommend running this via root SSH access, but either method will work the same and executes the same EasyApache tool, just via different access methods (i.e., command-line/CLI using SSH, or via your root WHM control panel access).

    Related documentation:
    ApachePHPRequestHandling < EasyApache3 < TWiki
    ConfigurePhp < AllDocumentation/WHMDocs < TWiki
    RebuildPhpconf < AllDocumentation/WHMDocs < TWiki
    EasyApache < AllDocumentation/WHMDocs < TWiki
    Apache & cPanel/WHM

Share This Page