Ubuntu 26.04

Mail Server : Mail Log Report : AWstats2026/06/08

 

Install Mail Log reporting tool, AWstats.

[1]

Install Apache2, refer to here.

[2] Change the format of the mail.log file that Rsyslog records.
root@mail:~#
vi /etc/rsyslog.d/50-default.conf
# line 14 : change the format of the mail.log
mail.*                          -/var/log/mail.log;RSYSLOG_TraditionalFileFormat

root@mail:~#
systemctl restart rsyslog
[3] Install and Configure AWstats.
root@mail:~#
apt -y install awstats
root@mail:~#
cp /usr/share/doc/awstats/examples/maillogconvert.pl /usr/share/awstats/tools/

root@mail:~#
vi /etc/awstats/awstats.conf
# line 50 : change
LogFile="/usr/share/awstats/tools/maillogconvert.pl standard < /var/log/mail.log |"

# line 62 : change
LogType=M

# line 126 : comment out and add the line
#LogFormat=4
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"

# line 157 : specify your hostname
SiteDomain="mail.srv.world"

# line 867 : change like follows
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForSearchEnginesDetection=0
LevelForKeywordsDetection=0
LevelForFileTypesDetection=0
LevelForWormsDetection=0

# line 980 : change like follows
ShowSummary=HB
ShowMonthStats=HB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=HB
ShowHostsStats=HBL
ShowAuthenticatedUsers=0
ShowRobotsStats=0
ShowWormsStats=0
ShowEMailSenders=HBML
ShowEMailReceivers=HBML
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowFileSizesStats=0
ShowDownloadsStats=0
ShowOSStats=0
ShowBrowsersStats=0
ShowScreenSizeStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowHTTPErrorsPageDetail=0
ShowSMTPErrorsStats=1
ShowClusterStats=0

root@mail:~#
vi /etc/apache2/conf-available/awstats.conf
# create new
Alias /awstats-icon/ /usr/share/awstats/icon/
Alias /awstatsclasses/ /usr/share/java/awstats/

<Directory /usr/share/awstats>
    Options FollowSymLinks
    AllowOverride None
    # scope of access permission
    Require ip 127.0.0.1 10.0.0.0/24
</Directory>

root@mail:~#
a2enconf awstats

Enabling conf awstats.
To activate the new configuration, you need to run:
  systemctl reload apache2

root@mail:~#
a2enmod cgid

Enabling module cgid.
To activate the new configuration, you need to run:
  systemctl restart apache2

root@mail:~#
systemctl restart apache2
# generate reports ( reports are updated per 10 minutes by Cron )

root@mail:~#
/usr/share/awstats/tools/update.sh

root@mail:~#
/usr/share/awstats/tools/buildstatic.sh

[4] Access to the URL [(your server's hostname or IP address/)/cgi-bin/awstats.pl] from any client computer on allowed network with web browser. Then you can see mail log reports.
Matched Content