/fake-smtp-server

This is a fake smtp server to execute script when receiving email. Can be used to interface camera with domotic applications.

Primary LanguageC++

Fake-Smtp-Server

Fake-smtp-server allows you to execute script when a device is trying to send an email.
It can be used to interface a domotic devices such as a camera, with a domotic server (such as Domoticz).

Supported platforms

  • Ubuntu 16.04 (Xenial)
  • Raspbian 8.0 (Jessie)

Dependencies

  • Standard C++ librairies
  • Boost

Compilation

sudo apt install cmake
sudo apt install libboost-filesystem-dev
git clone https://github.com/PicoI2/fake-smtp-server
cd fake-smtp-server
cmake .
make

How to use it

Modify or create your own script in the execution directory.
The second line of each script file (*.sh) is read by fake-smtp-server which used it as a regular expression.
You could use for example :

.*
MAIL FROM: <sender@mail.com>
RCPT TO: <receiver@mail.com>
Subject: Motion detected by camera

Then add to your script file any command, such as sending info to your domotic server
curl -s http://domoticz:8080/json.htm?type=command&param=switchlight&idx=39&switchcmd=On&username=MkE=&password=OVM=
Create an "attachments" folder in the execution directory to get access to attached files.

Create service

Open fake-smtp-server.service and modify ExecStart and WorkingDirectory, to set path of application and execution directory (where scripts are). Then enter these commands :

sudo cp fake-smtp-server.service /lib/systemd/system/
sudo systemctl enable fake-smtp-server.service
sudo systemctl start fake-smtp-server.service

If you want to disable the service :

sudo systemctl stop fake-smtp-server.service
sudo systemctl disable fake-smtp-server.service