← back to Ventura Claw
server/connectors/purelymail.js
33 lines
// Purelymail — REAL. Uses Purelymail HTTPS API (the Account API token, not SMTP).
// Docs: https://purelymail.com/docs/api
const API = "https://purelymail.com/api/v0";
function token(c) { const t = c?.PURELYMAIL_API_TOKEN || process.env.PURELYMAIL_API_TOKEN; if (!t) throw new Error("PURELYMAIL_API_TOKEN not set"); return t; }
async function call(method, path, body, c) {
const r = await fetch(`${API}${path}`, {
method,
headers: { "Purelymail-Api-Token": token(c), "Content-Type": "application/json" },
body: body ? JSON.stringify(body) : "{}"
});
const d = await r.json().catch(() => ({}));
if (!r.ok || d.type === "error") throw new Error(`purelymail ${path}: ${d.message || r.status}`);
return d;
}
module.exports = {
meta: { id: "purelymail", name: "Purelymail", category: "email", docsUrl: "https://purelymail.com/docs/api", auth: "api_key", realImpl: true },
fields: [{ key: "PURELYMAIL_API_TOKEN", label: "Account API Token", type: "password", required: true, hint: "purelymail.com > account > API tokens" }],
configured(c) { return !!(c?.PURELYMAIL_API_TOKEN || process.env.PURELYMAIL_API_TOKEN); },
async health(c) {
if (!this.configured(c)) return { ok: false, reason: "no_token" };
try { const d = await call("POST", "/listUser", {}, c); return { ok: true, account: d.result?.[0] || "verified" }; }
catch (e) { return { ok: false, reason: e.message }; }
},
actions: {
async "domains.list"(_, c) { return call("POST", "/listDomains", {}, c); },
async "users.list"(_, c) { return call("POST", "/listUser", {}, c); },
async "user.create"({ userName, password, domain }, c) {
if (!userName || !password || !domain) throw new Error("userName, password, domain required");
return call("POST", "/createUser", { userName, password, domain }, c);
}
}
};