https://github.com/0xdeface/h2s
h2s is small service for sending email messages. Work with it is very simply.
https://github.com/0xdeface/h2s
http smtp
Last synced: about 2 months ago
JSON representation
h2s is small service for sending email messages. Work with it is very simply.
- Host: GitHub
- URL: https://github.com/0xdeface/h2s
- Owner: 0xdeface
- Created: 2022-07-25T00:20:41.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-26T05:36:39.000Z (over 3 years ago)
- Last Synced: 2024-06-20T13:29:46.666Z (almost 2 years ago)
- Topics: http, smtp
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# H2S [http to smtp]
[](https://github.com/0xdeface/h2s/actions/workflows/go.yml)
## 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":"Интернет заказ в магазине"}'
```