cxSend
Auto-generated documentation from JSDoc comments
cxSend¶
A component to send Email and SMS messages asynchronously via a job queue.
Example¶
import cxSend from 'cxSend';
export async function main(data) {
// Send an email
const emailJob = await cxSend.email({
to: '[email protected]',
subject: 'Message title',
text: 'Plaintext version of the message',
html: '<p>HTML version of the message</p>'
});
// Send an SMS
const smsJob = await cxSend.sms('+447000123456', 'Hello World!');
return { emailJob, smsJob };
}
Kind: global class
- cxSend
- .email(params) ⇒
Promise.<object>|string|number|number - .sms(number, message) ⇒
Promise.<object>|string|number|number
- .email(params) ⇒
cxSend.email(params) ⇒ Promise.<object> | string | number | number¶
Send an email message
Kind: static method of cxSend
Returns: Promise.<object> - Job details including id, timestamp, and statusstring - return.id - Unique job identifiernumber - return.timestamp - Job creation timestampnumber - return.attemptsMade - Number of delivery attempts
| Param | Type | Description |
|---|---|---|
| params | object |
Email parameters |
| params.to | string |
Recipient email address |
| params.subject | string |
Email subject line |
| [params.text] | string |
Plain text version of the message |
| [params.html] | string |
HTML version of the message |
| [params.from] | string |
Sender email address (optional, uses default if not provided) |
| [params.cc] | string |
CC recipients (comma-separated) |
| [params.bcc] | string |
BCC recipients (comma-separated) |
Example
// Simple email
await cxSend.email({
to: '[email protected]',
subject: 'Hello',
text: 'Hello World!'
});
// HTML email with all options
const job = await cxSend.email({
to: '[email protected]',
subject: 'Welcome!',
text: 'Welcome to our service',
html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>'
});
console.log('Email queued with job ID:', job.id);
cxSend.sms(number, message) ⇒ Promise.<object> | string | number | number¶
Send an SMS message
Kind: static method of cxSend
Returns: Promise.<object> - Job details including id, timestamp, and statusstring - return.id - Unique job identifiernumber - return.timestamp - Job creation timestampnumber - return.attemptsMade - Number of delivery attempts
| Param | Type | Description |
|---|---|---|
| number | string |
Recipient telephone number in E.164 format (e.g., '+447000123456') |
| message | string |
SMS message content (max 160 characters for single SMS) |
Example
// Send a simple SMS
await cxSend.sms('+447000123456', 'Hello World!');
// Send SMS and track the job
const job = await cxSend.sms('+447000123456', 'Your verification code is 123456');
console.log('SMS queued with job ID:', job.id);