sending the log with SSMTP:
- configure SSMTP as explained in chapter 4.8 in this manual
- Install sharutils (contains uuencode):
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install sharutils
- create the script to send the log as attachment:
sudo nano sendlog.sh
- enter the command:
echo -e "to: <your_account_name>@gmail.com\nsubject: pihole log\n"| (cat - && uuencode /var/log/pihole.log pihole.log) | /usr/sbin/ssmtp <your_account_name>@gmail.com
everything on one line, replace <your_account_name> with the correct mail address (twice), you will basically send a mail to yourself. - make the script executable:
sudo chmod 755 ./sendlog.sh
- test the script:
./sendlog.sh
if you received a mail, containing the attachment, you probably need to open it with an editor that understands unix formatted text files, I use notepad++ - to automate this, on a daily base, create a cron file
sudo nano /etc/cron.d/sendlog
- enter the job
56 23 * * * root PATH="$PATH:/home/pi" sendlog.sh
this will mail the log at 23h56, you need to allow sufficient time to read and send the log, before the pihole script flushes it at 00h00
if the developers would implement logrotation (or you are implementing it yourself), you would be able to run the cron job the next day e.g.
00 05 * * * root PATH="$PATH:/home/pi" sendlog.sh
you would need to change the filename from pihole.log to pihole.log.1 e.g.
echo -e "to: <your_account_name>@gmail.com\nsubject: pihole log\n"| (cat - && uuencode /var/log/pihole.log.1 pihole.log.1) | /usr/sbin/ssmtp <your_account_name>@gmail.com
hope this helps...