I have Proxmox Mail Gateway (PMG) and I need to add subject information to the log. This subject is needed to get detailed information about the email that has been sent. So, I can trace the email in the log with this message trace.
Below is what I did
Go to RuleDB folder
cd /usr/share/perl5/PMG/RuleDB
Backup Accept.pm
cp Accept.pm Accept.pm-ori
Open Accept.pm
vi Accept.pm
Add this line before “if ($qid) {” (line 126)
syslog('info', "$qid: warning: header Subject: %s from $msginfo->{fqdn}", PMG::Utils::decode_rfc1522(PVE::Tools::trim($entity->head->get('subject'))) || 'No Subject');
So the line will be like this
Restart pmg-smtp-filter
systemctl restart pmg-smtp-filter
Now, you can see the subject information on the log
Feb 14 21:18:01 pmg pmg-smtp-filter[13026]: 80CA81C1076: warning: header Subject: Test sending email to imanudin.net from pmg.imanudin.web.id Feb 14 21:18:01 pmg pmg-smtp-filter[13026]: 1C107563EB981976CAC: accept mail to(80CA81C1076) (rule: default-accept)
And you can trace with the zmmsgtrace script here: How To Add Subject Information on Message Trace
The results
/srv/zmmsgtrace /var/log/mail.log Tracing messages Message ID '20230214211801.007912@ThinkPad-X230' Subject 'Test sending email to imanudin.net' admin@imanudin.web.id --> admin@imanudin.net Recipient admin@imanudin.net Feb 14 21:18:01 - localhost.localdomain (127.0.0.1], orig_client=unknown[192.168.1.11) --> 192.168.1.21:25 (192.168.1.21:25) status sent
If you need PMG Support and Subscription, please feel free to contact my Company: https://www.excellent.co.id/kontak/
Good luck 🙂
One comment