@sunney/flareutils
Version:
Small Utilities and little goodies that make developing with Cloudflare easier and faster.
20 lines • 842 B
JavaScript
/**
* Helper to quickly send emails with the MailChannels API.
* @note This helper function performs no verification of your inputs, and should only be used for utilizing types with MailChannels.
* @param {MailChannelsOptions} opts Options that the MailChannels API may accept when sending an email.
* @returns {Promise<Response>} Response from the MailChannels API.
* @example ```ts
* await sendMail({from: {email: "user@example.com"}, content: [{type: "text/plain", value: "Hello, world!"}]});
* ```
*/
export async function sendMail(opts) {
return fetch("https://api.mailchannels.net/tx/v1/send", {
headers: {
"content-type": "application/json",
accept: "application/json",
},
method: "POST",
body: JSON.stringify(opts),
});
}
//# sourceMappingURL=MailChannels.js.map