Send transactional email to one recipient. Email can contain text and/or html representation.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('communication/send-email@2.2.0');
// Use the profile
const result = await profile
.getUseCase('SendEmail')
.perform({
from: 'no-reply@example.com',
to: 'jane.doe@example.com',
subject: 'Your order has been shipped!',
text: 'Hello Jane, your recent order on Our Shop has been shipped.',
attachments: [
{
filename: 'order.pdf',
type: 'application/pdf',
content: 'JVBERi0xLjQKJeLjz9MKMyAwIG9...'
}
]
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"from": "no-reply@example.com",
"to": "jane.doe@example.com",
"subject": "Your order has been shipped!",
"text": "Hello Jane, your recent order on Our Shop has been shipped.",
"attachments": [
{
"filename": "order.pdf",
"type": "application/pdf",
"content": "JVBERi0xLjQKJeLjz9MKMyAwIG9..."
}
]
}
{
"messageId": "JpITLjVBS3iknTzDq1BKPg"
}