How to send an email using a Docklet associated with a template

To send one or more emails, a request should be made to the endpoint using POST with a valid JSON. The unique attribute necessary is the to, a list with one or more containers. Each list item is a dictionary containing the following fields:

  • email*
  • name
  • merge_var
  • attachment


It’s mandatory to inform the recipient’s email. The other fields are optional.

The sender's data, Name, Email and Subject will be rescued from the saved template and used to format the email that will be sent.

The merge_vars field is a dictionary that will be injected into the template context to customize the fields. In this dictionary you can inject as many customization variables as you wish. This context even affects the Subject that can be customized as well.

"merge_vars": {"birthdate":"02/08/1984", "gender":"male"}

The fields customization in the Template is made by changing automatically the template variables for the variables injected by merge_vars. The syntax used in the templates is the Jinja2 syntax with all features.

Let's see a complete example:


<html> <body> Customization test<br> Name: \{\{\}\}<br> Email: \{\{\}\}<br> Birthdate: \{\{birthdate\}\}<br> Gender: \{\{gender\}\}<br> </body> </html>

Note that the variable fields are delimited by \{\{ \}\}. Whenever there is a delimited content by \{\{ \}\} the system will try changing variables injected through merge_vars.

That even goes for the email Subject such as:

Subject: Welcome \{\{\}\}

RESTful Request

Run a request

Method: post
Authorization: Basic
Content-Type: application / json

{ "to": [{ "name": "Full Name", "email": "", "merge_vars": {"birthdate":"02/08/1984", "gender":"male"} }] }

Here is the same example sent by Curl

"curl -­?v -­?-­?user 933ff2214029fffe19c:8107ff48ff6bc4fb19 -­?H "Content-­?Type: application/json" -­?d {"to": [{ "name":"Full Name", "email":"", "merge_vars": {"birthdate":"02/08/1984", "gender":"male"} }] }

The Basic Authorization must be used, passing the API KEY and the API SECRET as data for authentication.


The result of the post, if the JSON is correctly formatted and the authorization was given, is a JSON containing a list of each one of the emails sent and a unique event identifier.

201 Created


API Libraries

Through our libraries you will be able to do a fast integration between Maildocker and your project with a variety of languages and frameworks. We keep the following official libraries for you to send your transactional emails:

maildocker-nodejs - Official NodeJS library
maildocker-php - Official PHP library
maildocker-python - Official Python library
maildocker-ruby - Official Ruby library

Code Examples


".. code:: javascript