Results 1 to 6 of 6

Thread: see which php scripts are sending mail?

  1. #1
    Member
    Join Date
    Jul 2010
    Posts
    16

    Default see which php scripts are sending mail?

    is there any way to do this?

    also, is there an easy way to get a summary of most recent exim messages sent including the subject?

  2. #2
    Member kuldeep_'s Avatar
    Join Date
    Apr 2010
    Posts
    54

    Default

    To trace php script sending email, first you will need root SSH access to server and enable log selector for exim which will help you to generate extra/well defined logs for exim.

    To do this Access WHM as root. Access Service Configuration >> Exim Configuration Editor. Click on Advance Editor.

    Under exim.conf section you will see #!!# cPanel Exim 4 Config
    and you can add following code in the text box.

    log_selector = +address_rewrite +all_parents +arguments +connection_reject +delay_delivery +delivery_size +dnslist_defer +incoming_interface +incoming_port +lost_incoming_connection +queue_run +received_sender +received_recipients +retry_defer +sender_on_delivery +size_reject +skip_delivery +smtp_confirmation +smtp_connection +smtp_protocol_error +smtp_syntax_error +subject +tls_cipher +tls_peerdn
    Now checking exim logs:

    tail -f /var/log/exim_mainlog | grep cwd
    Above command will grep for current working directory for exim and show the directory path from which email are being sent.

    Mostly if email are sent from script then in exim logs you will see email sent form cpaneluser@serverhostname.tld

    If you see there are multiple email in email queue with name cpaneluser@serverhostname.tld then you can check headers for the message.

    To check email header use command

    exim -Mvh Message-id
    In the header section locate for X-PHP-Script: and that will show you the exact script i.e sending email

  3. #3
    Member
    Join Date
    Jul 2010
    Posts
    16

    Default

    I seem to be getting

    " exim -Mvh 1OoLkg-0007fj-Hj
    Failed to open input file for 1OoLkg-0007fj-Hj-H: No such file or directory
    "

    for everyone one i attempt

  4. #4
    Member kuldeep_'s Avatar
    Join Date
    Apr 2010
    Posts
    54

    Default

    Quote Originally Posted by alexmack View Post
    I seem to be getting

    " exim -Mvh 1OoLkg-0007fj-Hj
    Failed to open input file for 1OoLkg-0007fj-Hj-H: No such file or directory
    "

    for everyone one i attempt
    It seems that message ID 1OoLkg-0007fj-Hj was already delivered to recipient and so you are not able to read it.

    But still you can view email subject, check your exim logs carefully
    grep 1OoLkg-0007fj-Hj /var/log/exim_mainlog
    and you will see T=" " this section contains email subject included into double quote.

    Also check email queue, if there are any other email present then you can use command exim -Mvh Message-ID

  5. #5
    Member
    Join Date
    Jul 2010
    Posts
    16

    Default

    is there any way to add the php script logging to the exim_main log?

  6. #6
    Member kuldeep_'s Avatar
    Join Date
    Apr 2010
    Posts
    54

    Default

    Quote Originally Posted by alexmack View Post
    is there any way to add the php script logging to the exim_main log?
    You can try one thing.
    If you have CSF firewall installed then you can edit /etc/csf/csf.conf file and enable a feature LF_SCRIPT_ALERT = "1" and set the email script limit to LF_SCRIPT_LIMIT = "300"

    i.e If more then 300 email are found to be sent from a script then you will receive an alert.

Similar Threads

  1. CGI scripts not sending email, php scripts will
    By BianchiDude in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 11-17-2006, 04:20 AM
  2. how to find nobody scripts sending mail
    By salvatore333 in forum cPanel & WHM Discussions
    Replies: 25
    Last Post: 11-15-2006, 01:59 AM
  3. scripts not sending mail after update?
    By lbeachmike in forum cPanel & WHM Discussions
    Replies: 4
    Last Post: 10-08-2006, 03:25 PM
  4. Problems Sending Mail From Scripts
    By a1022 in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 04-24-2002, 09:39 PM
  5. Problems Sending Mail From Scripts
    By a1022 in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 10-15-2001, 09:29 AM