Send application email with the MailKite SDK
Send one approved message through the MailKite server SDK and record acceptance separately from delivery.
Reviewed
After verifying your sending domain, install the server SDK with npm install mailkite. Supply MAILKITE_API_KEY, APP_FROM, and TEST_TO securely at runtime. The sender must use your approved domain; the recipient must be an address you control or have permission to contact.
Send one controlled message
Save this as an ES module. Running it sends real mail:
import { MailKite } from "mailkite";
for (const key of ["MAILKITE_API_KEY", "APP_FROM", "TEST_TO"]) {
if (!process.env[key]) throw new Error(`Missing ${key}`);
}
const mk = new MailKite(process.env.MAILKITE_API_KEY);
const result = await mk.send({
from: process.env.APP_FROM,
to: process.env.TEST_TO,
subject: "Controlled application test",
text: "A message from the approved application sender.",
});
console.log({ id: result.id });
Persist your intended send before making the call and associate the returned identifier with that record. Do not log keys, complete message bodies, or password-reset URLs.
Verify and recover
Check the dashboard message record and controlled recipient. An API success is acceptance, not proof of final inbox placement. If the connection fails after submission, investigate the existing message record before retrying and risking a duplicate.
A domain, permission, suppression, or account-limit error needs correction at that boundary; changing sender addresses to evade the check is not a recovery strategy. Use sending documentation for the current request, error, and delivery contract. Connect the receiving guide separately if the application also handles replies.