cloudflare
Version:
The official TypeScript library for the Cloudflare API
71 lines • 2.94 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import * as SuppressionsAPI from "./suppressions.mjs";
import { BaseSuppressions, Suppressions, } from "./suppressions.mjs";
import * as SubdomainsAPI from "./subdomains/subdomains.mjs";
import { BaseSubdomains, Subdomains, } from "./subdomains/subdomains.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseEmailSending = /* @__PURE__ */ (() => {
class BaseEmailSending extends APIResource {
/**
* Send an email for the specified account using the structured builder. Provide
* the sender, recipients, subject, and at least one of text or html; attachments
* are optional.
*
* @example
* ```ts
* const response = await client.emailSending.send({
* account_id: 'account_id',
* from: 'sender@example.com',
* subject: 'Monthly Report',
* });
* ```
*/
send(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/email/sending/send`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Send a raw RFC 5322 (MIME) email for the specified account. Provide the full
* MIME message plus the SMTP envelope (from and recipients).
*
* @example
* ```ts
* const response = await client.emailSending.sendRaw({
* account_id: 'account_id',
* from: 'sender@example.com',
* mime_message:
* 'From: sender@example.com\r\nTo: recipient@example.com\r\nSubject: Hello\r\nContent-Type: text/plain\r\n\r\nHello, World!',
* recipients: ['recipient@example.com'],
* });
* ```
*/
sendRaw(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/email/sending/send_raw`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseEmailSending._key = Object.freeze(['emailSending']);
return BaseEmailSending;
})();
export var EmailSending = /* @__PURE__ */ (() => {
class EmailSending extends BaseEmailSending {
constructor() {
super(...arguments);
this.suppressions = new SuppressionsAPI.Suppressions(this._client);
this.subdomains = new SubdomainsAPI.Subdomains(this._client);
}
}
EmailSending.Suppressions = Suppressions;
EmailSending.BaseSuppressions = BaseSuppressions;
EmailSending.Subdomains = Subdomains;
EmailSending.BaseSubdomains = BaseSubdomains;
return EmailSending;
})();
//# sourceMappingURL=email-sending.mjs.map