- Registriert
- 30. März 2022
- Beiträge
- 593
- Reaktionspunkte
- 1.041
- Punkte
- 184
@framp
You can send emails via a script using DSM's ssmtp. Though it's not a simple one line of code (more like 68 lines if you want to make it bullet-proof). You could strip it down to about 13 lines if you removed all the checking.
The script needs to create a txt file that contains the to and from email addresses, subject and the body of the email.
Have a look at the function in https://github.com/007revad/Linux_Plex_Backup/blob/develop/Linux_Plex_Backup.sh from line 175 to 234.
NOTE: Change msmtp to ssmtp for DSM.
Add the following near the top of the script:
Then you'd need to add the following later in the script where you want to send to the email:
You can send emails via a script using DSM's ssmtp. Though it's not a simple one line of code (more like 68 lines if you want to make it bullet-proof). You could strip it down to about 13 lines if you removed all the checking.
The script needs to create a txt file that contains the to and from email addresses, subject and the body of the email.
Have a look at the function in https://github.com/007revad/Linux_Plex_Backup/blob/develop/Linux_Plex_Backup.sh from line 175 to 234.
NOTE: Change msmtp to ssmtp for DSM.
Add the following near the top of the script:
Code:
to_email_address=you@gmail.com
from_email_address=you@gmail.com
email_directory=/tmp
Then you'd need to add the following later in the script where you want to send to the email:
Code:
# Send log via email if both logging and emails are enabled
if [[ $to_email_address && $from_email_address ]]; then
echo -e "\nSending email..."
email_contents="email_contents.txt"
send_email "$to_email_address" "$from_email_address" "$email_directory" "$email_contents" "$script log"
fi