-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ SMTP_PORT= | |
SMTP_USERNAME= | ||
SMTP_PASSWORD= | ||
SENDER_EMAIL= | ||
SENDER_NAME= | ||
SENDER_NAME= | ||
PORT=3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Mail Queue | ||
### Description | ||
Microservice to send email asyncrhonusly by sending `address`, `subject`, and `content`. | ||
### Usage | ||
#### Instalation : | ||
- Clone this project | ||
- Make sure your machine has Go with minimum version 1.13 | ||
- Run `go get` on this directory | ||
- Run `go mod download` too | ||
- Type `go run main.go` | ||
#### Routes : | ||
`/` (GET) : index | ||
`/send` (POST) : sending email | ||
#### Environment : | ||
copy `.env.example` to `.env` and fill the requirements. | ||
> - SMTP_HOST : host of your SMTP server | ||
> - SMTP_PORT : port of your SMTP server | ||
> - SMTP_USERNAME : username of your SMTP server | ||
> - SMTP_PASSWORD : password of your SMTP server | ||
> - SENDER_EMAIL : email of sender | ||
> - PORT : port of this microservice | ||
#### Example : | ||
In this case i used GuzzleHttp on Laravel for example | ||
```php | ||
$g = new \GuzzleHttp\Client(); | ||
$addresses = ["[email protected]", "[email protected]"]; | ||
$content = new \App\Mail\InvoiceCreated(\App\Invoice::first()); | ||
$data = [ | ||
"addresses" => $addresses, | ||
"email" => [ | ||
"subject" => "Testing World", | ||
"content" => $content->render() | ||
] | ||
]; | ||
$g->postAsync("http://0.0.0.0:3000/send", [\GuzzleHttp\RequestOptions::JSON => $data])->wait(); | ||
``` | ||
Data : | ||
``` | ||
[ | ||
"addresses" => $addresses, | ||
"email" => [ | ||
"subject" => $subject | ||
"content" => $content | ||
] | ||
] | ||
] | ||
``` | ||
`$addresses` : Array of target email | ||
`$content` : Content of email (HTML format) | ||
`$subject` : Subject email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters