# Alerts sending issue to an email from local host emoncms

**URL:** <https://community.openenergymonitor.org/t/alerts-sending-issue-to-an-email-from-local-host-emoncms/16316>\
**Category:** Emoncms\
**Tags:** emoncms\
**Created:** [22 December 2020 19:56 UTC](https://community.openenergymonitor.org/t/alerts-sending-issue-to-an-email-from-local-host-emoncms/16316 "2020-12-22T19:56:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Usman36264](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/u/9e8a1a/32.png) [@Usman36264](https://community.openenergymonitor.org/u/Usman36264)\
**Post date:** [22 December 2020 19:56 UTC](https://community.openenergymonitor.org/t/alerts-sending-issue-to-an-email-from-local-host-emoncms/16316/1 "2020-12-22T19:56:08Z")

</div>

I am struggling with sending email alerts (to an email address) for specific cases from my logs in emoncms. Any help in this regard would be appreciated.

---

<div class="post-metadata">

**Author:** ![johnbanks](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/c6cbf5/32.png) [@johnbanks](https://community.openenergymonitor.org/u/johnbanks)\
**Post date:** [23 December 2020 21:16 UTC](https://community.openenergymonitor.org/t/alerts-sending-issue-to-an-email-from-local-host-emoncms/16316/2 "2020-12-23T21:16:39Z")

</div>

@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 …

> [@Configuring "send email process"?](https://community.openenergymonitor.org/t/configuring-send-email-process/15009):
>
> Is there a guide how the “send email process” is set up working ? At least the below seems to work, but its linking to a detached swiftmailer git HEAD… also it took quite some time to figure out so wondering if there is an easier to find way ? Install swiftmailer: git -C /opt/emoncms/modules clone -b ‘v5.4.8’ --single-branch [GitHub - swiftmailer/swiftmailer: Comprehensive mailing tools for PHP](https://github.com/swiftmailer/swiftmailer.git) Then add the following with your own email server info to the end of the /var/www/emoncms/settin…

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) …

```auto
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:

```auto
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 name@gmail.com
user name@gmail.com
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.

```auto
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:

> **[Business SMS: Text Messaging Service Since 2001 | Textmagic](https://www.textmagic.com/business-text-messaging/)**
>
> Textmagic is a business text messaging service for sending SMS messages, notifications, alerts, reminders and text message marketing campaigns. Free Trial!

Texts are sent as if an email to: [MobileNumber@textmagic.com](mailto:MobileNumber@textmagic.com) They cost 4p.

Hope some of this may help.
