Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Wanting to count number of emails a single account sends in X time

Discussion in 'E-mail Discussion' started by domeneas, Nov 23, 2017.

  1. domeneas

    domeneas Active Member

    Sep 20, 2013
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator

    so I have used whmapi1 emailtrack_user_stats to get the total number of emails sent in a given time for each account on my cpanel servers, but I would like to be able to count the amounts of email a single email account has sent to write an auto suspend script for just that account if it goes over certain limits. Stopping all mail to the cpanel account seems overkill.

    The easiest way I can see is if I could get a hold of the number that WHM's "Email Delivery Report" returns (The search matches X records at the top of the page) when I search for an exact match for a From Address.

    Is that possible? Or is there a UAPI or API2 command I've overlooked or some other easy way?

    I'm trying to avoid writing something of my own that searches exim_mainlog and counts.
    I have used:
    exigrep '<= .* H=' /var/log/exim_mainlog | fgrep '<=' 
    for a test so far, and it does return only sent emails it seems, but in a live test it returned about 1790 records vs the delivery reports almost 2200.

    #1 domeneas, Nov 23, 2017
    Last edited: Nov 23, 2017
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator

    First, I'd like to provide you with some information about a new feature in cPanel version 68:

    This allows you to receive an email notification if an individual email account exceeds 500 unique outbound messages in an hour.

    As far as your custom script, the WHM API 1 function you may find useful is:

    WHM API 1 Functions - emailtrack_search - Software Development Kit - cPanel Documentation

    Or, if you were willing to spend some more time developing a custom script that scans for eximstats data, you can take a look at the following file for an example of how we collect eximstats data:

    There's also a thread here you may find helpful:

    Fetch data from sqlite database

    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice