Why?
Some services have an option to send notifications by email, so we need to install a simple sendmail emulator which could forward messages to relay mail host.
For example, sendmail could be used to notify you about failed drive in RAID array via google mail.
Prerequisites
- Created google mail account.
- Installed entware-ng with
opkg
. Follow this article: https://www.artembutusov.com/libreelec-entware-ng-installation/ - SSH access to LibreELEC.
Installation
Login over SSH.
Install msmtp
sendmail-like MTA:
opkg install msmtp
nano /opt/etc/msmtprc
account gmail
host smtp.gmail.com
port 587
from {account}@gmail.com
user {account}@gmail.com
auth on
password {secret}
domain {host}
syslog LOG_MAIL
tls on
tls_trust_file /opt/etc/ssl/certs/ca-certificates.crt
account default : gmail
Test
You should have your regular email account, for example user@domain.com
.
So you could test and send email to yourself from your LibreELEC:
echo test | sendmail user@domain.com
You should get an email after running code below.
Troubleshooting
If you did not get an email you could try to debug issue (add -v
):
echo test | sendmail user@domain.com -v
For google mail here are some well known issues (make sure you are logged out from your personal account and logged in with your account designated to be used on LibreELEC):
- Less secure apps: https://myaccount.google.com/lesssecureapps
- Unlock Captcha: https://accounts.google.com/DisplayUnlockCaptcha
Conclusion
Now you could use sendmail in various custom scripts to notify yourself over email.
Dear Artem, thank you for your great article! I use “LibreELEC (official) – Version: 8.0.2” but there is no sendmail installed by default. As well I cannot find sendmail, mail oder mailx in opkg package list. Maybe you can help me?
Hi again! I got it… “echo test | msmtp user@domain.com” does the trick.
If you have properly set PATH variable then sendmail should be available. By default it is installed into /opt/sbin/sendmail