Dirvish Email Notification
Collect and send information about images by email at end of the dirvish cron job.
You get a single email with a status summary for all vaults processed in the cron job run. By default the summary and log files are attached to the mail for convenience, as well as the file rsync_error in case it was created. Which files are attached can be configured.
Mail Setup
- Make sure that mutt is installed and you can send mail with it
- Check with
echo „My Content“ | mutt -s „My Subject“ your.name@yourdomain.com
- Below is a brief tutorial for using an external mailserver by smtp.
- Find instructions in the internet for other setups.
- Download the latest release
- Extract archive, and upload these files to /etc/dirvish:
- mail.conf
- dirvish-mail
- dirvish-cronjob-mail
- Make files /etc/dirvish/dirvish-mail and /etc/dirvish/dirvish-cronjob-mail executable by chmod 755
- Edit mail.conf
- Remove # in front of
#mail_to john.doe@example.com
, and change the email address. - The line shoud finally look somewhat like
mail_to your.name@yourdomain.com
- Enter
/etc/dirvish/dirvish-mail post-server
as post-server script in your master.conf.- In case you do not want all vaults reported, add it to the post-server script of each single vault, instead of master.conf.
- Use dirvish-cronjob-mail in place of dirvish-cronjob for your cron job
- In case you are using a customized script for your cron job, please check README.md in the zip archive how to edit it.
Send email via external mail server
If you dont need a full email environment on the dirvish server itself, you can use an external mailserver. That might be your own mailserver, or any provider like gmail, swisscom, web.de where you have an email account.
Here is a very brief example setup for debian using msmtp. You can find more detailed tutorials in the internet if you need special options, just search for „msmtp“.
#apt install -y msmtp msmtp-mta mailutils
Show locations of the the msmtp configuraton files:
# msmtp --version msmtp Version 1.8.3 ... System configuration file name: /etc/msmtprc User configuration file name: /root/.msmtprc ...
Edit the system configuration file.
# nano /etc/msmtprc defaults port 587 tls on tls_trust_file /etc/ssl/certs/ca-certificates.crt account accountname host smtp.example.com from john.doe@example.com auth on user emailaccount password emailpassword account default: accountname aliases /etc/aliases
- Replace accountname with something like „mymail“, „bygmail“ etc.
- Replace smtp.example.com with the smtp url of your mailserver.
- Replace john.doe@example.com by your email address.
- Replace emailaccount by your email account name
- Replace emailpassword by your email password
Change access for security:
# chmod 600 /etc/msmtprc
Add aliases:
# nano /etc/aliases ... root: your.name@your_email_server.com default: your.name@your_email_server.com
Set msmtp as the sendmail program:
# nano /etc/mail.rc set sendmail="/usr/bin/msmtp -t"
Test if working so far with the „mail“ program:
# echo "My Content" | mail -s "My Subject" your.name@yourdomain.com
Finally add mutt and test if that also works:
# apt install -y mutt # mutt (accept creation of ~/Mail directory) (press q to quit) # echo "My Content" | mutt -s "My Subject" your.name@yourdomain.com
Note to msmtp 1.8.3 in debian 10 (buster)
You may notice that the envelope and the return address is from your email servers domain (@your_email_server.com), but the sender address is from the hostname of your dirvish server (@dirvishserver). It seems that the alias expanding only works with newer versions of msmtp. It might look harmless or even useful at first sight, however it will increase the spam-score of your email by the receiving mailserver. To work around, set the domain of your mailserver in /etc/mailname:
# nano /etc/mailname your_email_server.com