Inhaltsverzeichnis

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

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

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