Skip to content

0xdeface/h2s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

H2S [http to smtp]

Go

Description

h2s is small service for sending email messages. Work with it is very simply.
H2S do render html template with your own data and send it to recipient.
First: Put your template inside tpls folder. H2S support go template syntax.
Second: Make http post query with payload to endpoint.

Required env variables

SMTP_HOST 
SMTP_PORT 
SMTP_SSL 
SMTP_TSL 
SMTP_USERNAME 
SMTP_PASSWORD

Additionally, you can set HTTP_PORT variable, if not set default is ":8090". This variable is responsible for the port listening port.

Required payload fields

{
"templateName": "target_template.html",
"data" : "data for you template",
"subject" : "email subject",
"to" :["array of recipients",]
"from" : "email from"
}

Endpoints

/send [POST] - synchronous rendering html and sending to recipient
/send-async [POST] - asynchronous returning uuid of job
/result?uuid= [GET] - returning result previously added job /test - returning rendered template without sending smtp message

Usage

Run service ./h2s
Send request. Example with curl bellow

curl localhost:8090/send --data '{"templateName":"ecommerce.html", "data":{"name":"test1", "sum":"4584", "order":"d-12323", "products":[{"name":"LG TV sdfdsfdsfsdf", "price": "777.0", "quantity":"44", "sum":"3434 руб"},{"name":"Product 2 lololo", "price":"343434", "quantity":"dsfsdfsdf", "sum":"sdfsdf"}]}, "from":"sender@rix.ru", "to":["recipent.khv@gmail.com"],"subject":"Интернет заказ в магазине"}'

About

h2s is small service for sending email messages. Work with it is very simply.

Topics

Resources

Stars

Watchers

Forks

Contributors