Edits history of script submission #1268 for ' Send an email (resend)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Resend = {
      token: string;
    };
    /**
     * Send an email
     *
     */
    export async function main(
      auth: Resend,
      body: {
        from: string;
        to: string[];
        subject: string;
        bcc?: string;
        cc?: string;
        reply_to?: string;
        html?: string;
        text?: string;
        headers?: { [k: string]: unknown };
        attachments?: {
          content?: string;
          filename?: string;
          path?: string;
          [k: string]: unknown;
        }[];
        tags?: { name?: string; value?: string; [k: string]: unknown }[];
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.resend.com/emails`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 399 days ago

  • nativets
    type Resend = {
      token: string;
    };
    /**
     * Send an email
     *
     */
    export async function main(
      auth: Resend,
      body: {
        from: string;
        to: string[];
        subject: string;
        bcc?: string;
        cc?: string;
        reply_to?: string;
        html?: string;
        text?: string;
        headers?: { [k: string]: unknown };
        attachments?: {
          content?: string;
          filename?: string;
          path?: string;
          [k: string]: unknown;
        }[];
        tags?: { name?: string; value?: string; [k: string]: unknown }[];
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.resend.com/emails`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 960 days ago

  • nativets
    export type Resend = {
      token: string;
    };
    /**
     * Send an email
     *
     */
    export async function main(
      auth: Resend,
      body: {
        /**   * Sender email address. To include a friendly name, use the format "Your Name <[email protected]>".   */ from: string;
        to: string[];
        /**   * Email subject.   */ subject: string;
        /**   * Bcc recipient email address. For multiple addresses, send as an array of strings.   */ bcc?: string;
        /**   * Cc recipient email address. For multiple addresses, send as an array of strings.   */ cc?: string;
        /**   * Reply-to email address. For multiple addresses, send as an array of strings.   */ reply_to?: string;
        /**   * The HTML version of the message.   */ html?: string;
        /**   * The plain text version of the message.   */ text?: string;
        /**   * Custom headers to add to the email.   */ headers?: {
          [k: string]: unknown;
        };
        attachments?: {
          /**     * Content of an attached file.     */ content?: string;
          /**     * Name of attached file.     */ filename?: string;
          /**     * Path where the attachment file is hosted     */ path?: string;
          [k: string]: unknown;
        }[];
        tags?: {
          /**     * The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (09), underscores (_), or dashes (-). It can contain no more than 256 characters.     */ name?: string;
          /**     * The value of the email tag.It can only contain ASCII letters (a–z, A–Z), numbers (09), underscores (_), or dashes (-). It can contain no more than 256 characters.     */ value?: string;
          [k: string]: unknown;
        }[];
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.resend.com/emails`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      return await response.json();
    }
    

    Submitted by rubenfiszel 961 days ago