This docker allows mocking the real Sendgrid Rest Server.
Being specially useful when testing it speeds up mail automation, eliminating the need to poll for services like real email servers (gmail, etc.) or Mailinator.
docker run -d --name mailserver -p 3000:3000 tfsoares/sendgrid-mock
This will store the sent email on memory, allowing the recipient to be searched.
The endpoint used is: POST http://<docker_gateway>/api/mail.send.json
in place of the real service endpoint POST https://api.sendgrid.com/api/mail.send.json
.
The configurations would be:
require('sendgrid')(sendgrid_username, sendgrid_password, {
"protocol":"http",
"host": "<docker_gateway>",
"port":3000
});
new SendGrid("SENDGRID USERNAME", "SENDGRID_PASSWORD")
.setUrl("http://<docker_gateway>:3000");
This endpoint will allow knowing if an email sending has been requested.
GET http://<docker_gateway>:3000/api/mail.read.json/<email_to_search>
{ "total": <how_may_mails>, "results": [<mails>] }
This will clear all cached emails. This can not be reversed.
GET http://<docker_gateway>:3000/api/mail.clear.json
{ "message": "success", "errors": [] }
To run this docker you will need to have Docker and installed. You can also just run the bash script build_and_run.sh
.
- mhart/alpine-node for the awesomely small Alpine-based Node.js images