Code Monkey home page Code Monkey logo

smtp2mqtt's Introduction

Build Status Circle Status

smtp2mqtt

Simple SMTP to MQTT relay/forwarder.

Ever wanted to just forward your alert e-mails to MQTT? smtp2mqtt can do it.

Features

  • Single executable (thanks to Go!)
  • Linux/Windows/Mac/BSD support
  • multipart text/html e-mails supported
  • (optional) JSON support

Examples

Here is quick example, just to get idea what you can do with it.

Quick Examples

Start server:

$ ./smtp2mqtt -listen 0.0.0.0:10025
2019/10/22 21:51:25 Listening on: 0.0.0.0:10025

Run SMTP server forwarder and forward to MQTT 192.168.1.1 in JSON:

$ ./smtp2mqtt -json -topic smtp/ -mqtt tcp://192.168.1.1:1883
2019/10/22 21:52:25 Listening on: 0.0.0.0:10025

Download

You can find binary and source releases on Github under "Releases". Here's the link to the latest release

Options explained

$ ./smtp2mqtt
Usage of ./smtp2mqtt:
  -allow string
    	Allow only specific IPs to send e-mail (e.g. 192.168.1.)
  -debug
    	Enable debug messages
  -deny string
    	Deny specific IPs to send e-mail (e.g. 192.168.1.10)
  -json
    	post to MQTT topic as json
  -keep
    	keep connection to MQTT
  -listen string
    	Listen on specific IP and port (default "0.0.0.0:10025")
  -mqtt string
    	connect to specified MQTT server (default "tcp://127.0.0.1:1883")
  -password string
    	MQTT password for connecting
  -topic string
    	prepend specified string to MQTT topic (e.g. 'smtp/')
  -user string
    	MQTT username for connecting
  -version
    	Display version
  -welcome string
    	Welcome message for SMTP session (default "MQTT-forwarder ESMTP ready.")

Building

Linux/Mac/POSIX builds

Just type:

go build

Static compiling:

CGO_ENABLED=0 go build -ldflags "-extldflags -static"

Windows builds

Just type:

go build

ToDo

  • Implement TLS support for MQTT

Done

  • Implement JSON support

Credits

Vlatko Kosturjak

smtp2mqtt's People

Contributors

kost avatar

Stargazers

Alex Sherry avatar  avatar Brian Elliott Finley avatar Jason Todd avatar loosik avatar Liam Gray avatar  avatar  avatar Brian Gibbins avatar H avatar Luis Alberto  avatar  avatar  avatar

Watchers

 avatar  avatar James Cloos avatar  avatar  avatar

smtp2mqtt's Issues

502 AUTH not supported

Hello, I am trying to use this smtp2mqtt server to receive email from my IP camera when they detected motion to trigger stuff on my home automation system.

It seems that I cannot configure my camera to properly connect, however I have been able to connect to the smtp2mqtt from thunderbird email client as well as directly sending SMTP commands over telnet both from the same box that the server is running on as well as other boxes on my LAN.

In trying to debug this I stopped smtp2mqtt and started a dummy SMTP server that just prints what it receives to the console. It seems that my camera tries to connect with the following:

Incoming connection from ('192.168.1.136', 55023)
Peer: ('192.168.1.136', 55023)
Data: 'EHLO localhost'
Data: 'HELO localhost'
Data: 'AUTH LOGIN'
Data: 'QUIT'

So then I stopped my dummy SMTP server and restarted smtp2mqtt. Next I connected via telnet and entered the same commands to see what the response was from smtp2mqtt, here is what I got:

tom@mythfe:~$ telnet 192.168.1.50 10025
Trying 192.168.1.50...
Connected to 192.168.1.50.
Escape character is '^]'.
220 MQTT-forwarder ESMTP ready.
helo test
250 Go ahead
AUTH LOGIN
502 AUTH not supported.

So, it seems that auth login is not supported and that my camera then closes the connection when receiving this command - since it cannot proceed

I am starting the server with a uname/passwd defined so I am surprised this is rejected:

./smtp2mqtt_linux_amd64 -json -topic orbital/motion -mqtt tcp://127.0.0.1:1883 -listen 192.168.1.50:10025 -user test -password test -debug

There seems to be no way to stop my camera from sending this auth string. Is this expected behavior for this server?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.