Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morkid/go-mailer-api
Golang Mailer Rest API and CLI
https://github.com/morkid/go-mailer-api
Last synced: about 1 month ago
JSON representation
Golang Mailer Rest API and CLI
- Host: GitHub
- URL: https://github.com/morkid/go-mailer-api
- Owner: morkid
- Created: 2020-04-16T13:13:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-10T10:47:32.000Z (about 4 years ago)
- Last Synced: 2023-09-28T16:23:04.554Z (over 1 year ago)
- Language: Go
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Send email with Rest API or CLI
Simple way to send email over **Rest API** and **CLI**.
Build app (golang required):
```bash
go get -d
go build -o mailer .
mailer --help
```# CLI options
type `mailer --help` to display all available options
```
-attachment value
Set email attachments
-bcc value
BCC, define multiple to send more than one bcc
-body string
Set email body
-cc value
CC, define multiple to send more than one cc
-debug
enable debug (default false)
-endpoint string
Start http with endpoint (default "/")
-from string
Set Sender email
-help
Display this help
-host string
Set email host
-http
Enable http server
-password string
Set email password
-plain-text
Send email as plaintext. (default false)
-port int
Start http with port (default 8080)
-provider string
Set email provider, eg: gmail
-single
single email per receiver. (default false)
-subject string
Set email subject
-to value
Receiver Email, define multiple to send more than one receiver
-username string
Set email username
```# Send email using CLI
Example:
```bash
mailer --provider gmail \
--from [email protected] \
--password s3cr3t \
--to [email protected] \
--to [email protected] \
--subject "Send from cli" \
--body "Hello world" \
--attachment file1.txt \
--attachment file2.txt
```
Don't forget to enable less secure apps to your gmail as a sender
[Enable less secure apps](https://support.google.com/a/answer/6260879)# Send email using Rest API
You must start http server before send email using Rest API:
```
mailer --http --port 8765 --endpoint /api/v1/mailer
```Send email using curl:
```
curl -X POST \
-H 'Content-type: application/json' \
-d '{
"from": "[email protected]",
"password": "s3cr3t",
"to": [
"[email protected]"
],
"subject": "Send from Rest API",
"body": "Hello world",
"attachments": [
{
"name": "image.png",
"data": "data:image/png,base64,TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQ="
}
]
}' \
http://localhost:8765/api/v1/mailer
```