The problem
Every application ends up sending email: confirmations, invoices, alerts. Talking to the SMTP server directly means handling timeouts, TLS, retries and a server that is down exactly when the message matters, in every application and in every language.
How DMSContainer solves it
Your application puts the message in the queue of the Email Module with one JSON-RPC call and goes on. The email job sends it, retries on errors, and keeps every message with its status, so you can see from the web console what was sent, what failed and why.
Before the first call, give the sending user an SMTP sender in the web console (Users, SMTP sender): host, port, credentials and TLS mode stay in DMSContainer, never in your applications.
Python
import requests
URL = "https://dms.example.com/emailrpc" # your DMSContainer
USER, PASSWORD = "my_user", "my_password"
def call(method, *params):
r = requests.post(URL, json={"jsonrpc": "2.0", "id": 1, "method": method, "params": list(params)}).json()
error = r.get("error") or (r.get("result") or {}).get("error")
if error:
raise RuntimeError(error["message"])
return r["result"]
token = call("Login", USER, PASSWORD)["token"]
message = {
"msgtolist": "customer@example.com",
"msgsubject": "Your invoice 2026/1024",
"msgbody": "Dear customer, your invoice is ready.",
"msgbodyhtml": "<p>Dear customer, your invoice is <b>ready</b>.</p>",
}
result = call("SendMessage", token, message)
print("queued, message id", result["messageid"]) # the email job sends it, retrying on errors
JavaScript (Node.js)
// Node.js 18 or later (built-in fetch)
const URL = "https://dms.example.com/emailrpc"; // your DMSContainer
const USER = "my_user", PASSWORD = "my_password";
async function call(method, ...params) {
const response = await fetch(URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
});
const r = await response.json();
const error = r.error || (r.result && r.result.error);
if (error) throw new Error(error.message);
return r.result;
}
(async () => {
const { token } = await call("Login", USER, PASSWORD);
const { messageid } = await call("SendMessage", token, {
msgtolist: "customer@example.com",
msgsubject: "Your invoice 2026/1024",
msgbody: "Dear customer, your invoice is ready.",
});
console.log("queued, message id", messageid);
})();
JavaScript in a web page
The same call from the browser: the user signs in with their own DMSContainer account (never write credentials in the page). Serve the page over HTTPS.
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Send an email</title>
<form id="form">
<input id="user" placeholder="DMSContainer user" autocomplete="username" required>
<input id="password" type="password" placeholder="Password" autocomplete="current-password" required>
<input id="to" type="email" placeholder="Recipient" required>
<input id="subject" placeholder="Subject" required>
<textarea id="body" placeholder="Message" required></textarea>
<button>Send</button>
</form>
<p id="status"></p>
<script>
const ENDPOINT = "https://dms.example.com/emailrpc"; // your DMSContainer
async function call(method, ...params) {
const response = await fetch(ENDPOINT, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
});
const r = await response.json();
const error = r.error || (r.result && r.result.error);
if (error) throw new Error(error.message);
return r.result;
}
document.getElementById("form").addEventListener("submit", async (event) => {
event.preventDefault();
const status = document.getElementById("status");
try {
const { token } = await call("Login", document.getElementById("user").value,
document.getElementById("password").value);
const { messageid } = await call("SendMessage", token, {
msgtolist: document.getElementById("to").value,
msgsubject: document.getElementById("subject").value,
msgbody: document.getElementById("body").value,
});
status.textContent = "Queued, message id " + messageid;
} catch (error) {
status.textContent = error.message;
}
});
</script>
</html>
curl
Any language that can make an HTTP request can do the same:
# 1. sign in: the answer holds the token
curl -s https://dms.example.com/emailrpc -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"Login","params":["my_user","my_password"]}'
# 2. queue the message (TOKEN = the token received above)
curl -s https://dms.example.com/emailrpc -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"SendMessage","params":["TOKEN",
{"msgtolist":"customer@example.com","msgsubject":"Your invoice 2026/1024",
"msgbody":"Dear customer, your invoice is ready."}]}'
The result
The call returns at once with the id of the queued message. The message also supports HTML bodies, attachments, templates for bulk sending and delayed delivery.