extension-email-raw

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Email — Raw Multi-Recipient

邮件——多收件人原生发送

Raw multi-recipient email extension for Caffeine AI.
适用于Caffeine AI的多收件人原生邮件扩展。

Overview

概述

This skill adds support for sending emails with multiple
to
,
cc
, and
bcc
recipients. Not suitable for bulk service emails (recipients see each other).
该Skill支持发送包含多个
to
(收件人)、
cc
(抄送人)和
bcc
(密件抄送人)的邮件。不适用于批量服务邮件(收件人会看到彼此的信息)。

Backend

后端

This extension is for sending an email with support for multiple
to
,
cc
and
bcc
addresses.

本扩展用于发送支持多个
to
cc
bcc
地址的邮件。

  • This should NOT be used for sending service emails to multiple users because each recipient will see all the other recipients listed which would typically be a breach of user privacy.
  • 请勿将其用于向多个用户发送服务邮件,因为每个收件人都会看到所有其他收件人的信息,这通常会违反用户隐私。

For sending an email

发送邮件步骤

  • This extension depends on the extension-email for sending emails.
  • Use the sendRawEmail function.
  • It returns a SendResult which is #ok if the email is sent successfully otherwise #err(error) with the error text.
  • There can be a maximum of 50 recipients in total
  • Each recipient receives the same email
mo
module {
  public type SendResult = {
    #ok;
    #err : Text;
  };

  public func sendRawEmail(
    fromUsername : Text,
    to : [Text],
    cc : [Text],
    bcc : [Text],
    subject : Text,
    htmlBody : Text,
  ) : async SendResult;
};
  • 本扩展依赖extension-email来发送邮件。
  • 使用sendRawEmail函数。
  • 它会返回一个SendResult:如果邮件发送成功则为#ok,否则为#err(error)并附带错误文本。
  • 收件人总数最多为50个
  • 每个收件人收到的邮件内容相同
mo
module {
  public type SendResult = {
    #ok;
    #err : Text;
  };

  public func sendRawEmail(
    fromUsername : Text,
    to : [Text],
    cc : [Text],
    bcc : [Text],
    subject : Text,
    htmlBody : Text,
  ) : async SendResult;
};

Example usage for sending an email reminder to meeting attendees.

向会议参与者发送邮件提醒的示例用法

motoko
import Runtime "mo:core/Runtime";
import EmailClient "mo:caffeineai-email/emailClient";

actor {
  public func sendMeetingReminder(
    meetingSubject : Text,
    meetingTime : Text,
    confirmedAttendeeEmails : [Text],
    tentativeAttendeeEmails : [Text],
  ) : async () {
    let result = await EmailClient.sendRawEmail(
      "no-reply",
      confirmedAttendeeEmails,
      tentativeAttendeeEmails,
      [],
      meetingSubject,
      "Reminder the meeting will start at " # meetingTime,
    );

    switch (result) {
      case (#ok) {};
      case (#err(error)) {
        Runtime.trap("Failed to send meeting reminder email: " # error);
      };
    };
  };
};
motoko
import Runtime "mo:core/Runtime";
import EmailClient "mo:caffeineai-email/emailClient";

actor {
  public func sendMeetingReminder(
    meetingSubject : Text,
    meetingTime : Text,
    confirmedAttendeeEmails : [Text],
    tentativeAttendeeEmails : [Text],
  ) : async () {
    let result = await EmailClient.sendRawEmail(
      "no-reply",
      confirmedAttendeeEmails,
      tentativeAttendeeEmails,
      [],
      meetingSubject,
      "Reminder the meeting will start at " # meetingTime,
    );

    switch (result) {
      case (#ok) {};
      case (#err(error)) {
        Runtime.trap("Failed to send meeting reminder email: " # error);
      };
    };
  };
};