From ea94c6b94d01fd6e087f9a5528ced6bbac11d252 Mon Sep 17 00:00:00 2001 From: Danya Sliusar Date: Sun, 10 Nov 2019 18:58:07 +0300 Subject: [PATCH] Add: more examples to README --- Dockerfile | 2 +- Makefile | 1 - README.md | 47 +++++++++++++++++++++++++++++++++++++++++------ main.go | 7 +++---- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index de664ca..44a469c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM interlegis/alpine-postfix +FROM interlegis/alpine-postfix:3.3.0 LABEL maintainer="Danya Sliusar " diff --git a/Makefile b/Makefile index ba39711..17fdc97 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ APP_NAME=sendmail-http - all: build build: diff --git a/README.md b/README.md index a3915e9..f1ad739 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,55 @@ # sendmail http -Simple http server for sendmail (based on postfix alpine) + + +Simple http server with Email sending. Now support Sendmail and Mutt as backend. + + ## Build -Binary can be built by execute: + -``` -make build +Binary can be built by *make*: +```bash +make build +# this creates binary in *bin* directory +ls bin/ +# sendmail-http ``` -To make docker image exec: +To make Docker image: +```bash +make docker +# or building by your own image +docker build -t your-own/sendmail-http . ``` -make docker +## Running +```bash +# Running directly with Docker +docker run -d -t --name sendmail \ + -p 1001:1001 \ + danyanya/sendmail-http:latest +# or by docker-compose +docker-compose up -d ``` + +## Usage + +For send email use **/api/sendmutt** endpoint: + +```bash +# Get params are from, to, subject and body: +curl -sSl localhost:1001/sendmutt?from=bill.gates@microsoft.com&to=steve.jobs@apple.com&subject=[job%20offer]&body=Confirmation,$%20Steve! + +# Also it accepts file, but it needed to be in container! +#!! &file=/tmp/some.xls +``` + +## Copyright + +Repo created by Daniil Sliusar at 2019. diff --git a/main.go b/main.go index e5c3d4a..246f781 100644 --- a/main.go +++ b/main.go @@ -81,7 +81,7 @@ func main() { var apiGroup = e.Group("/api") - // GET HTTP endpoint to send Emails with sendmail + // GET HTTP endpoint to send emails via sendmail apiGroup.GET("/sendmail", func(c echo.Context) error { var req = mailReq{} @@ -101,8 +101,8 @@ func main() { ) }) + // GET HTTP endpoint to send emails via mutt apiGroup.GET("/sendmutt", func(c echo.Context) error { - var req = mailReq{} if err := c.Bind(&req); err != nil { return c.JSON(http.StatusBadRequest, @@ -120,8 +120,7 @@ func main() { ) }) - var err = e.Start(serverAddr) - if err != nil { + if err := e.Start(serverAddr); err != nil { panic(err.Error()) }