Hello,
in the Apple discussions I found another thread regarding Server 5.2/macOS Sierra which describes the problem and provides a workaround based on the log command and cron.
Server 5.2 missing SMTP Logs
This was not really a solution for me, because I want to use fail2ban with postfix and the workaround suggested by the user "mac mini dabbler" always replaces the entire mail.log file and then completely reads the entire content again. So I made some changes to his concept and perhaps this also helps you and other users.
My workaround consists of two steps:
1. Add a script to get the log entries of the last minute of several SMTP processes and append them to the file /var/log/mail.log
2. Add a cron job to launch this script every minute
Step 1:
open Terminal
add a directory called scripts in /usr/local and go to that directory
#sudo mkdir /usr/local/scripts && cd /usr/local/scripts
then use nano to edit and save a file called maillog.sh to that directory
#sudo nano maillog.sh
Please paste the following code to that file:
---- copy below that line ----
#!/bin/bash
THEN=$(date -v-1M +"%Y-%m-%d %T")
NOW=$(date +"%Y-%m-%d %T")
if [ ! -f /var/log/mail.log ]
then
touch /var/log/mail.log
fi
/usr/bin/log show --start "$THEN" --end "$NOW" --predicate '(process == "smtp") || (process == "smtpd") || (process == "postscreen") || (process == "qmgr")' -info >> /var/log/mail.log
---- copy above that line ----
Then press "ctrl-o" to save the file and after that "ctrl-x" to quit nano.
To make the file executable you need to enter
#sudo chmod a+x maillog.sh
Step 2:
#sudo env EDITOR=nano crontab -e
Paste the following text into the nano editor:
---- copy below that line ----
MAILTO=""
*/1 * * * * /usr/local/scripts/maillog.sh
---- copy above that line ----
Then press "ctrl-o" to save the file and after that "ctrl-x" to quit nano.
Enter
#sudo crontab -l
to check, if the crontab exists.
Then open the console app and go to /var/log and check, if the mail.log file is present and becomes filled.
It might not be a perfect solution for everyone, but for me it works OK.