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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

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

Tags:
  1. domeneas

    domeneas Active Member

    Joined:
    Sep 20, 2013
    Messages:
    32
    Likes Received:
    2
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Hi,

    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:
    Code:
    exigrep '<= .*@example.com 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.

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

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    41,396
    Likes Received:
    1,605
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    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:

    Code:
    /usr/local/cpanel/scripts/eximstats_spam_check
    There's also a thread here you may find helpful:

    Fetch data from sqlite database

    Thank you.
     
Loading...

Share This Page