Need to store all emails adresse sent / received in one file

foxmedo

Active Member
Apr 21, 2014
36
0
56
cPanel Access Level
Root Administrator
Hello,

i need to store all emails send or received in one file

same as Mail Delivery Reports i need to store accepted mail only accepted

from Adresse and recipient any email received or sent

is there any script which can store this information ? the mail delivery reports give us only the last 5000

otherwise is there any way to extract this information from the logs only accepted
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,304
1,250
313
Houston
Are you wanting to do this for all mail on the server or just for a specific account? The exim logs note every single mail transaction that occurs on the server and it's where Mail Delivery Reports pulls its data from. You can modify the number of days exim stats are stored in the database at WHM>>Server Configuration>>Tweak Settings and use the emailtrack_search WHMAPI1 function to get the data WHM API 1 Functions - emailtrack_search - Developer Documentation - cPanel Documentation
 

foxmedo

Active Member
Apr 21, 2014
36
0
56
cPanel Access Level
Root Administrator
Thank you @cPanelLauren for your reply

i need to stock the maximum of information who send email to who some users come to ask about the report for the last 3months of their employee so we need to be able to answer theme saying you received email from this adresse and you send to this adresses

I have try with Mail Delivery Reports but when we filter and display 1000 in the first page we get empty result in second page 'No records found.' which is a bug i guess because in the first page we get 5000 result

i have increase the The interval, in days, to retain Exim stats in the database to 30 days but the Mail Delivery Reports will not show more than 5000 records
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,304
1,250
313
Houston
The method I provided you should give this but it would need to be appended as time goes on, i.e., every 5 days run the report and send the new data to the file.

Mail Delivery Reports specifically notes in the UI that it can only return the last 1000 results.

The only other option would be to store the exim logs indefinitely, in which case you'd want to move them once they're rotated. That way you could just search the logs any time you needed an answer for this. So if I needed all mail sent to and from any email address in the exim logs you could check it like this:
Code:
 egrep '=>|<=' /var/log/exim_mainlog |sort -u -k4 |awk -F',' '{ x[$1]=$0 } END { for (i in x) print x[i] }'
(this just prints one line for transactions that happen on multiple lines with the same message ID - you're just limited by the records that are currently present in the exim logs