apt install php8.2-{mysql,xml,zip,imap,mbstring}
A working webserver (not necessary)
apt install apache2
Create a new database for the application
CREATE DATABASE dmarc;
Create a new DB user
CREATE USER 'dmarc_user'@'localhost' IDENTIFIED BY '***********';
Grant permissions on new DB to new DB user
GRANT ALL ON dmarc.* TO 'dmarc_user'@'localhost';
Download the project
git clone https://github.com/liuch/dmarc-srg.git /var/www/dmarc-srg
Change ownership of the project files
chown www-data:www-data -R /var/www/dmarc-srg
Copy conf/conf.sample.php
to conf/conf.php
, then modify the new config file to fit your environment.
cp /var/www/dmarc-srg/config/conf.sample.php /var/www/dmarc-srg/config/conf.php
vim /var/www/dmarc-srg/config/conf.php
Here's an example of what my config looks like. (I removed all in-line comments to make it easier to read. Refer to the sample config in the project to view the author's comments)
<?php
$debug = 0;
$database = [
'host' => 'localhost',
'type' => 'mysql',
'name' => 'dmarc',
'user' => 'dmarc_user',
'password' => '*******************',
'table_prefix' => ''
];
$mailboxes = [
'name' => 'Dmarc-Rua',
'host' => 'mail.example.com',
'encryption' => 'ssl',
'novalidate-cert' => false,
'username' => 'dmarc-reports@example.com',
'password' => '******************',
'mailbox' => 'Inbox'
];
$admin = [
'password' => '*************',
];
//
$fetcher = [
'mailboxes' => [
'messages_maximum' => 40
],
'directories' => [
'files_maximum' => 50
],
'allowed_domains' => ''
];
$mailer = [
'from' => 'dmarc-reports@example.com',
'default' => 'ross@example.com'
];
//
$cleaner = [
'mailboxes' => [
'days_old' => 30,
'delete_maximum' => 50,
'leave_minimum' => 100,
'failed' => 'seen'
],
'reports' => [
'days_old' => 30,
'delete_maximum' => 50,
'leave_minimum' => 100
],
'reportlog' => [
'days_old' => 30,
'delete_maximum' => 50,
'leave_minimum' => 100
]
];
From inside the project root (/dmarc-srg), initialize the database
sudo -u www-data php utils/database_admin.php init
Configure the mailbox that receives reports
In the config above, the receiving mailbox should be setup and ready to use.
bash -c "cat > /etc/cron.d/dmarc-srg" <<'EOF'
0 * * * * www-data /usr/bin/php /var/www/dmarc-srg/utils/fetch_reports.php
0 0 * * * www-data /usr/bin/php /var/www/dmarc-srg/utils/mailbox_cleaner.php
EOF
Restart Cron
systemctl restart cron.service