Log every SMTP transaction in a MySQL database on SME Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
#!/bin/bash
LOG=$(/sbin/e-smith/db configuration getprop qpsmtpd Log2Sql || echo 'disabled')
if [ "$LOG" != "enabled" ]; then
exit 0
fi
RETENTION=$(/sbin/e-smith/db configuration getprop qpsmtpd Log2SqlRetention || echo 730)
DB=$(/sbin/e-smith/db configuration getprop qpsmtpd DbName || echo smtp_log)
echo "delete from rcpts where mail_id IN (select mail_id from messages where date_day<DATE_SUB(NOW(), INTERVAL $RETENTION DAY));" | mysql $DB
echo "delete from message_body where mail_id IN (select mail_id from messages where date_day<DATE_SUB(NOW(), INTERVAL $RETENTION DAY));" | mysql $DB
echo "delete from message_headers where mail_id IN (select mail_id from messages where date_day<DATE_SUB(NOW(), INTERVAL $RETENTION DAY));" | mysql $DB
echo "delete from messages where date_day<DATE_SUB(NOW(), INTERVAL $RETENTION DAY);" | mysql $DB