Configure your mailing gateway
Mailing Gateway : Introduction
A Mailing API Gateway is a service that facilitates communication between applications and email servers. It acts as an intermediary, allowing developers to send emails programmatically without directly interfacing with the complexities of email protocols and infrastructure.
By leveraging a Mailing API Gateway, developers can integrate email functionality into their applications with ease, enabling features such as transactional emails, notifications, newsletters, and more. These gateways often provide a simple and standardized interface, allowing developers to send emails using HTTP requests or SDKs in various programming languages.
Additionally, Mailing API Gateways often offer features like email tracking, delivery status notifications, and advanced email templating to enhance the functionality and user experience of email communication within applications. They play a crucial role in streamlining the process of sending and managing emails, making it more efficient and reliable for developers and users alike.
Prerequisites
First you need to create a route.
Then, you only need to add the MailerEndpoint
plugin to your route and configure it as following :
Plugin configuration
{
"host": "smtp.my.host", // the smtp server hostname
"port": 465, // the smtp server port
"user": "foo@my.host", // an optional username if authentication is enabled
"password": "xxxx", // an optional password if authentication is enabled
"auth": true, // enable authentication
"starttls_enabled": true, // opportunistic TLS upgrade on plain text connection
"smtps": true, // use TLS to contact the server
"max_retries": 5 // number of retries when email sending fails
}
request example
$ curl -X POST -H 'Content-Type: application/json' $YOUR_SERVERLESS_DOMAIN/messages -d '{
"subject": "Hello World",
"from": "hello@cloud-apim.com",
"to": ["<your email address>"],
"html": "<html><h1>Hello World</h1><p>Hello from <img src=\"cid:cloudapim.png\" /></p></html>",
"attachments": [
{
"name": "hello.txt",
"mimetype": "text/plain",
"content": "SGVsbG8gZnJvbSBDbG91ZCBBUElNICE="
},
{
"name":"cloudapim.png",
"mimetype":"image/png",
"disposition":"inline",
"content":"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAACZVJREFUaIHtWnlQFFca/153T/dc3TMDw6EcAgqKByioCasGNR6rUSq4HonX6mZDklq1LKvcjUajW6kcxhjLVNxoYkqyUUs8shHd6OrGLOqKroIKXn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