Alerts sending issue to an email from local host emoncms

@Usman36264

Input Processing does have a facility to send a data value to an email address.
Guide/Learn/Resources have no recent detailed explanation that I can find and the latest relevant Forum post seems to be …

But I have never tried to use this facility.

However I do use the emon system to send emails regarding aspects of the system operation as follows (working in an SSH terminal) …

Create a script that checks what I want and save it to /home/pi/check.things.sh (as an example)
Make the script executable with:  chmod+x /home/pi/check.things.sh
Create the message to be sent and save it to /home/pi/email.message.txt (as an example)
Create a cronjob to run the script at the desired times as follows:
Do: crontab -e and enter the following at the end then save and exit:

MAILTO=MyEmailAddress
1 0 * * sun /home/pi/check.things.sh
The above example runs the script at 00:01 every Sunday

However, the first time I tried this I had problems …

It is necessary to install an up to date mail transfer agent MTA as follows:

sudo apt-get install msmtp msmtp-mta mailutils

Then create the log file & open up permissions …

sudo touch /var/log/msmtp.log
sudo chmod 777 /var/log/msmtp.log

Then create the msmtp configuration file with the content shown …

sudo nano /etc/msmtprc

defaults
auth                 on
tls                     on
tls_trust_file  /etc/ssl/certs/ca-certificates.crt
logfile              /var/log/msmtp.log
account          gmail
host                smtp.gmail.com
port                587
from               [email protected]
user                [email protected]
password      GmailTwoFactorPassword
account default : gmail

Finally open up permissions by doing:
sudo chmod 777 /etc/msmtprc

You will note the references above to gmail.
I discovered that my ISP would not accept emails to my regular email address from an emon mail server (security issue?).
So I used my alternative gmail address and set up Two Factor Authentication.

You can send a test message with:

echo "Message" | mail -s "Title" MyEmailAddress

And read the log with:      tail -f /var/log/msmtp.log   

And if you’d prefer to use phone text messages rather than email then check out:

Texts are sent as if an email to: [email protected] They cost 4p.

Hope some of this may help.