# Outgoing/incoming mail stats?

**URL:** <https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952>\
**Category:** Community Support\
**Created:** [May 10, 2025, 11:17am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952 "2025-05-10T11:17:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sams2526](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sams2526](https://forum.hestiacp.com/u/sams2526)\
**Post date:** [May 10, 2025, 11:17am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/1 "2025-05-10T11:17:02Z")

</div>

Is there anything there that can show incoming/outgoing stats for each domain email etc?

Having sissues with a client that is trashing my primary mail server as a mailing list - they sending circa 9k emails a week ffs and [outlook.com](http://outlook.com) isnt happy with me.

Sam.

---

<div class="post-metadata">

**Author:** ![Felix](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/felix/32/32_2.png) [@Felix](https://forum.hestiacp.com/u/Felix)\
**Post date:** [May 10, 2025, 10:25pm UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/2 "2025-05-10T22:25:14Z")

</div>

Does this help?  
`grep '<=' /var/log/exim4/mainlog | awk '{print $5}' | grep \@ | sort | uniq -c | sort -nrk1 ; echo ""`

---

<div class="post-metadata">

**Author:** ![jlguerrero](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/jlguerrero/32/954_2.png) [@jlguerrero](https://forum.hestiacp.com/u/jlguerrero)\
**Post date:** [May 11, 2025, 12:34am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/3 "2025-05-11T00:34:00Z")

</div>

Thank you very much Felix.

I tried that command and it wasn’t that helpful because I got one count for every single email address in that log and many of them were temporary and auto generated.

After asking AI, I got this one…

```auto
grep '<=' /var/log/exim4/mainlog* | awk '{print $5}' | grep '@' | 
awk -F'@' '{print $2}' | 
awk -F. '{if ($(NF-1) == "co" || $(NF-1) == "com" || $(NF-1) == "net" || $(NF-1) == "org" || $(NF-1) == "gov" || $(NF-1) == "edu") print $(NF-2)"."$(NF-1)"."$NF; else print $(NF-1)"."$NF}' | 
sort | uniq -c | sort -nr

```

---

<div class="post-metadata">

**Author:** ![sams2526](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sams2526](https://forum.hestiacp.com/u/sams2526)\
**Post date:** [May 14, 2025, 8:41am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/4 "2025-05-14T08:41:35Z")

</div>

ok great that works but it doesnt touch the gz files.

mainlog mainlog.2.gz mainlog.5.gz mainlog.8.gz  
mainlog.1 mainlog.3.gz mainlog.6.gz mainlog.9.gz  
mainlog.10.gz mainlog.4.gz mainlog.7.gz

---

<div class="post-metadata">

**Author:** ![sahsanu](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sahsanu/32/10259_2.png) [@sahsanu](https://forum.hestiacp.com/u/sahsanu)\
**Post date:** [May 14, 2025, 8:51am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/5 "2025-05-14T08:51:05Z")

</div>

> [@sams2526](#):
>
> ok great that works but it doesnt touch the gz files.

Change `grep` with `zgrep`

---

<div class="post-metadata">

**Author:** ![sams2526](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sams2526](https://forum.hestiacp.com/u/sams2526)\
**Post date:** [May 17, 2025, 12:28am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/6 "2025-05-17T00:28:46Z")

</div>

Thanks that worked – is there a way to do a similar check but a specific domain and the emails tally per each email account too?

Just trying to isolate a potential password guess on an email. Have domain that shouldnt have so many outgoing emails. no rootkit found though so i am guessing may be a false positive or they guessed the password to the only email account on that domain.

---

<div class="post-metadata">

**Author:** ![sams2526](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sams2526](https://forum.hestiacp.com/u/sams2526)\
**Post date:** [May 17, 2025, 12:38am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/7 "2025-05-17T00:38:03Z")

</div>

actually i think this is tallying incoming too and the email adddress thats getting this high tally isnt a valid email. hmmmmmm. so many hits from russia/china though to that invalid email address.

---

<div class="post-metadata">

**Author:** ![sahsanu](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/sahsanu/32/10259_2.png) [@sahsanu](https://forum.hestiacp.com/u/sahsanu)\
**Post date:** [May 17, 2025, 1:08am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/8 "2025-05-17T01:08:50Z")

</div>

Try this.

To get a list of mails sent by your mail domains:

```t
list="$(for i in $(/usr/local/hestia/bin/v-list-users plain | cut -f1 | sort);do for a in $(/usr/local/hestia/bin/v-list-mail-domains $i plain | cut -f1);do echo "$(idn2 $a)";done; done | sort|sed -z -e 's/\n/|@/g' -e 's/^/@/' -e 's/|@$//')"; zgrep '<=' /var/log/exim4/mainlog* | awk '{print $5}' | awk -F'@' '{print "@"$2}' | sort | uniq -c | sort -n | grep -E "$list" | tr -d '@'

```

To get a list of mails sent by the accounts of your mail domains:

```t
list="$(for i in $(/usr/local/hestia/bin/v-list-users plain | cut -f1 | sort);do for a in $(/usr/local/hestia/bin/v-list-mail-domains $i plain | cut -f1);do echo "$(idn2 $a)";done; done | sort|sed -z -e 's/\n/|@/g' -e 's/^/@/' -e 's/|@$//')"; zgrep '<=' /var/log/exim4/mainlog* | awk '{print $5}' | sort | uniq -c | sort -n | grep -E "$list"

```

---

<div class="post-metadata">

**Author:** ![sams2526](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sams2526](https://forum.hestiacp.com/u/sams2526)\
**Post date:** [May 17, 2025, 7:40am UTC](https://forum.hestiacp.com/t/outgoing-incoming-mail-stats/18952/9 "2025-05-17T07:40:38Z")

</div>

brilliant Thank You!!!
