Smtp device

From ago control wiki
Jump to: navigation, search

This page is obsolete, to send messages see AgoAlert

Sending email

First, the SMTP device needs to be setup

Grab the python file from the GIT repository

wget http://www.agocontrol.com/trac/export/3fb39afe254673e5c13d196679cb7188572be34b/agocontrol.git/devices/smtp/agosmtp.py


Move it to the agocontrol bin directory.

sudo mv agosmtp.py /opt/agocontrol/bin/

and set the permissions

sudo chmod 755 /opt/agocontrol/bin/agosmtp.py

Create the configuration file.

sudo nano /etc/opt/agocontrol/config.d/smtp.conf

This is where we add all the info on the mail server. The below example is for a gmail or Google Apps address. If you use a different mail service you will need to look up the correct info for your service.

[smtp]
server=smtp.gmail.com
port=587
from=you@domain.com
authrequired=1
user=you@domain.com
password=yourpassword

Change ownership for consistency sake.

sudo chown agocontrol:agocontrol /etc/opt/agocontrol/conf.d/smtp.conf

Test it out by running it from the commandline

sudo python /opt/agocontrol/bin/agosmtp.py

The device should now be in the agocontrol admin under Configuration>Devices with a DeviceType of smtpgateway. Press the Action button next to the device to pull up the window that allows you to send an email. Add the message body, subject, and email address to send a test message. If the messsage does not go through, check the terminal to see if there are any error messages.

Assuming the test message goes through, you will want the device to run at startup, so you need to make it a service

Create a systemd service file

sudo nano /lib/systemd/system/agosmtp.service


[Unit]
Description=ago control SMTP Device

[Service]
ExecStart=/opt/agocontrol/bin/agosmtp.py
WorkingDirectory=/opt/agocontrol/bin
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=2
User=agocontrol

[Install]
WantedBy=multi-user.target

Make the file executable

sudo chmod +x /lib/systemd/system/agosmtp.service

Next, the service needs to be enabled and started

sudo systemctl enable agosmtp.service
sudo systemctl start agosmtp.service

Check back in the admin to see that the device is there. Add a name to the device like "Email" and it will now show up under "Actions" when you create Events.

Personal tools