This is a sub-service for the Inpaqt projects that sends emails to clients. It's important to note that the service currently only sends emails and does not store any templates within itself.
A strict message structure must be followed as shown below. Missing any parameter could lead to emails failing to send or the request failing altogether. Please follow the instructions below.
This is a POST request that needs to be sent to the 'emailservice/requesttoken'. This request should contain the following in the headers:
So an example curl request would look like this:
curl --location --request POST 'http://<MAIN_URL>/emailservice/requesttoken' \
--header 'key: your-project-key' \
--header 'name: your-prokect-name' \
--data ''
If the post request made by you is a valid one, you should recive a token. The token is required for the next step so keep that in mind and. The token is valid for 10 seconds only.
Now that you have the token from the previous request you can send an email.This is also a POST request, the request should contain the following in the headers:
Along with the request you also need to send a body that is a JSON object that contains a single key called 'message' its value should be stringified and based64 encode object with values as mentioned below.
How the object should look before encoding:
{
message: {
toEmail: "<Explained below>",
emailBody: "<Explained below>",
emailSubject: "<Explained below>"
emailBodyInText: "<Explained below>"
}
}
How the object should look after encoding:
{
message: "your-encoded-string"
}
So an example curl would look like this:
curl --location 'http://<MAIN_URL>/emailservice/sendemailroute' \
--header 'token: <your-valid-token>' \
--header 'Content-Type: application/json' \
--data '{
"message": "your-encoded-string"
}'
toEmail: This is the list of client emails. It must be in a valid format, such as [example@email.com, example@email.com, ..., ...,]. Requests with invalid email addresses will be rejected.
emailBody: This is the body of the email that you want to send. This can be both plain text or HTML. HTML allows your email to have a customized look when it gets rendered on the client side. When building the HTML email it is recommend that you treat the email as a webpage.
emailSubject: This is the subject of the email.
emailBodyInText: This section defines the content of the email in a simple, text-only format, similar to how you would type an email directly to your client. It supports basic formatting options but lacks the visual customization of HTML.
Here are some important points to consider:
* Including HTML code in this field will result in the code itself being displayed in the email client, not the intended visual elements.
* This parameter acts as a fallback for clients unable to render your HTML email. The reasons for this can vary and are beyond the scope of this documentation.