Skip to content
Verified

Send an email

Confirm outbound mail is wired up with one call, before a real notification depends on it.

test_email sends one real message through the same Stalwart submission path every platform email uses, @xuda.ai outbound, DKIM and SPF aligned. There is nothing to configure first: call it, check the inbox (or the error), and you know outbound mail works before anything else in your integration depends on it.

Method

POST/cpi/test_email
admin

Test Email

Runs a test for email.

Two more fields the registry does not list

test_email declares one mandatory field, email. The handler also reads an optional app_id (pulls that project's branding into the template; omitted means the platform's own Xuda branding) and an optional from (a different Xuda mailbox to send as, its own submission credential has to already exist server-side). Both are reproduced below from source, not from the registry.

Walkthrough

Send it

Just api_key and the address you want to receive the test at.

curl -s https://xuda.ai/cpi/test_email \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY","email":"[email protected]"}'
const res = await fetch('https://xuda.ai/cpi/test_email', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ api_key: 'YOUR_API_KEY', email: '[email protected]' }),
});
const { code, data } = await res.json();
if (code > 0) console.log('sent:', data.messageId, data.accepted);
else console.log('failed:', data);
import requests

res = requests.post(
    'https://xuda.ai/cpi/test_email',
    json={'api_key': 'YOUR_API_KEY', 'email': '[email protected]'},
)
body = res.json()
if body['code'] > 0:
    print('sent:', body['data']['messageId'], body['data']['accepted'])
else:
    print('failed:', body['data'])

The response

data is nodemailer's own SMTP result object, passed straight through:

json
{
  "code": 1,
  "data": {
    "accepted": ["[email protected]"],
    "rejected": [],
    "envelopeTime": 210,
    "messageTime": 340,
    "messageSize": 812,
    "response": "250 2.0.0 OK",
    "envelope": { "from": "[email protected]", "to": ["[email protected]"] },
    "messageId": "<[email protected]>"
  }
}

code: 1 means the submission server accepted the message for delivery, not that it landed in the inbox, accepted is the address list Stalwart itself confirmed, and a non-empty rejected on an otherwise code: 1 response means Stalwart accepted some recipients and refused others. There is no delivery webhook behind this call: a code: 1 response is the whole signal you get from test_email itself.

Errors

Next