Giter Club home page Giter Club logo

smtp2http's Introduction

SMTP2HTTP (email-to-web)

smtp2http is a simple smtp server that resends the incoming email to the configured web endpoint (webhook) as a basic http post request.

Dev

  • go mod vendor
  • go build

Dev with Docker

Locally :

  • go mod vendor
  • docker build -f Dockerfile.dev -t smtp2http-dev .
  • docker run -p 25:25 smtp2http-dev --timeout.read=50 --timeout.write=50 --webhook=http://some.hook/api

Or build it as it comes from the repo :

  • docker build -t smtp2http .
  • docker run -p 25:25 smtp2http --timeout.read=50 --timeout.write=50 --webhook=http://some.hook/api

The timeout options are of course optional but make it easier to test in local with telnet localhost 25 Here is a telnet example payload :

HELO zeus
# smtp answer

MAIL FROM:<[email protected]>
# smtp answer

RCPT TO:<[email protected]>
# smtp answer

DATA
your mail content
.

Docker (production)

Docker images arn't available online for now See "Dev with Docker" above

  • docker run -p 25:25 smtp2http --webhook=http://some.hook/api

Native usage

smtp2http --listen=:25 --webhook=http://localhost:8080/api/smtp-hook smtp2http --help

Contribution

Original repo from @alash3al Thanks to @aranajuan

smtp2http's People

Contributors

alash3al avatar aranajuan avatar armandmgt avatar devster avatar stouch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smtp2http's Issues

Empty response

I send "test mail" via thunderbird but $_POST and $_GET response is empty. Why?

Docker image is sending "application/x-www-form-urlencoded"

I discovered in a lengthy nightsession that the current version of your docker image is sending the POST not in application/json but in application/x-www-form-urlencoded. This behavior is only seen in the docker image and not in your Linux and Windows releases. Based on the docker build timestamp (which is after your v3.1 release), I was expecting to see application/json

Webhook from Docker image alash3al/smtp2http:latest
image

Webhook from same system but Linux binary
image

My workaround is to use the Linux binaries but I wanted to document it here in case other have the same issues.
Maybe you find time to look into it ๐Ÿ˜„

PS: Thanks very much for this awesome piece of software!

Issue getting the utility

root@chat-srv1:/home/chat# go get github.com/uflare/smtp2http

# github.com/uflare/smtp2http
/root/work/src/github.com/uflare/smtp2http/handler.go:25:33: cannot use req.Message (type *mail.Message) as type io.Reader in argument to parsemail.Parse:
	*mail.Message does not implement io.Reader (missing Read method)
/root/work/src/github.com/uflare/smtp2http/handler.go:30:8: undefined: resty.R

Charset error with french mails containing accents because of hotmail (Windows-1252)

Hello,

The mails sent from the french Microsoft outlook and hotmail.com are sent with Content-Type: text/plain; charset="Windows-1252" charset.

So the payload in hook seems to be badly encoded and the chars and I finally receive are some non-recoverable ๏ฟฝ dead chars.

Do you think there is some easy solution to this ?

Thank you so much for your work.

Spamassassin support?

I am guessing this is meant to be a replacement for the unmaintained Mailin software?

One neat feature of Mailin was that you could easily parse emails with spamassassin for a spam score and remove emails accordingly, before triggering any webhooks.

Thanks for looking into this.

501 MAIL command contained invalid address (in reply to MAIL FROM command)

Hello ,

First of all, thanks you all for the contributions.

I have a business scenario, which to received all customer's email request and store it in backend to further processing. I find this repository is exactly matched. So I kickoff with a cloud server and install your binary with command:
./smtp2http-linux-amd64 --listen=:25 --webhook=http:///api/key/smtp2http --name=.cn --strict=false

Then I open my hotmail/ foxmail, start to send a email to this server, not sure what the receiver address should be, I just put it a randon adress like [email protected],( of cause, I have register the domain), then I got error message like
host myhost [.9.204] said: 501 MAIL command contained invalid address (in reply to MAIL FROM command)
As I check port 25, it is accessible from my laptop.

Is there any other configuration need to be done ?

8bitmime

Error: transaction failed, blame it on the weather: Cannot read your message: unknown encoding: 8bit"

Please add support of 8bitmime encoded messages

Cannot parse the name of the "From" field

It cannot parse the name part of From field. The sender in the example is a Gmail account so it sets the From field like:

From: John Doe <[email protected]> but payload doesn't have the name field.

Here is an example payload:

{
  "spf": "softfail",
  "id": "CAHg1ePJZcAw_qS0HQuXc4KATCvZORVbMCOfVmSuGt28PDTZk0A@mail.gmail.com",
  "date": "2023-09-12 11:55:37 +0300 +0300",
  "subject": "test",
  "resent_date": "0001-01-01 00:00:00 +0000 UTC",
  "body": {
    "text": "foobar",
    "html": "
foobar
"
  },
  "addresses": {
    "from": {
      "address": "[email protected]"
    },
    "to": {
      "address": "..."
    }
  }
}

"to" field is empty

Here's the SMTP exchange:

220 smtp2http ESMTP Service Ready
HELO zeus
250 2.0.0 Hello zeus
MAIL FROM:<stavros@zeus>
250 2.0.0 Roger, accepting mail from <stavros@zeus>
RCPT TO:<[email protected]>
250 2.0.0 I'll make sure <[email protected]> gets this
DATA
354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF>
Received: (nullmailer pid 142148 invoked by uid 1000);
	Wed, 10 Jun 2020 10:01:02 -0000
Date: Wed, 10 Jun 2020 13:01:02 +0300
Message-Id: <1591783262.002746.142147.nullmailer@zeus>
From: stavros <stavros@zeus>
Cc: recipient list not shown: ;

.
250 2.0.0 OK: queued
QUIT
221 2.0.0 Goodnight and good luck

And here's the received body:

{"spf":"temperror","id":"1591783262.002746.142147.nullmailer@zeus","date":"2020-06-10 13:01:02 +0300 EEST","resent_date":"0001-01-01 00:00:00 +0000 UTC","body":{},"addresses":{"from":{"name":"stavros","address":"stavros@zeus"},"to":[]}}

You can see that [email protected] is not shown anywhere, and it should be.

Pass all mail headers through

A good feature would be adding a "headers" list to the webhook so we can get every raw header in the original email message.

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.