Extension Email

作者 caffeinelabs362f51ae96f0無授權條款2 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Support for sending service/transactional emails. Don't use this for sending marketing emails or verification emails.

僅含說明Communication
AI 產生的概覽

透過預製的 Motoko 模組,為 Caffeine AI 後端 canister 加入服務性與交易性電子郵件寄送功能。

功能
此技能說明如何從 Caffeine AI 後端 canister 使用不可修改的預製模組 mo:caffeineai-email/emailClient.mo 寄送服務性與交易性電子郵件。內容介紹 sendServiceEmail 函式:接收寄件者使用者名稱、收件者清單、主旨與 HTML 內文,為每位收件者分別寄送郵件,並回傳 SendResult,成功為 #ok,失敗為 #err 並附上錯誤文字。文件也包含訂單確認郵件的 Motoko 使用範例,以及從 caffeineai-email 0.2.x 升級至 0.3.0 的說明,升級後每次寄送都會帶上幂等鍵。
適用情境
適用於建置需要寄送一次性服務性或交易性電子郵件(例如訂單確認、通知)的 Caffeine AI 應用程式。它明確不適用於行銷郵件或驗證郵件,這兩類由其他技能負責。
執行需求
需要 Caffeine AI 平台,並依賴 Mops 相依套件 caffeineai-email(版本 ~0.3.0),以及 plus 或 pro 訂閱。此技能不附帶指令碼,僅為說明文件,且所引用的 emailClient.mo 模組不可修改。

Email — Service/Transactional

Service/transactional email extension for Caffeine AI.

Overview

This skill adds support for sending service and transactional emails from the backend canister. Use sendServiceEmail for order confirmations, notifications, and similar one-off emails.

Backend

This component is for sending service/transactional emails.

There is the prefabricated module mo:caffeineai-email/emailClient.mo which cannot be modified.

  • Use the sendServiceEmail function.
  • Each recipient is sent an individual email
  • It returns a SendResult which is #ok if the email is sent successfully otherwise #err(error) with the error text.
mo:caffeineai-email/emailClient.mo
module {  public type SendResult = {    #ok;    #err : Text;  };
  public func sendServiceEmail(    fromUsername : Text,    recipients : [Text],    subject : Text,    htmlBody : Text,  ) : async SendResult;};

Usage for sendServiceEmail:

motoko
import Runtime "mo:core/Runtime";import EmailClient "mo:caffeineai-email/emailClient";
actor {  public func sendOrderConfirmationEmail(recipientEmailAddress : Text, username : Text, orderReference : Text) : async () {    let result = await EmailClient.sendServiceEmail(      "no-reply",      [recipientEmailAddress],      "Order " # orderReference # " confirmed",      "Hello " # username # ",\nYour order " # orderReference # " has been confirmed. Your items will ship tomorrow.",    );    switch (result) {      case (#ok) {};      case (#err(error)) {        Runtime.trap("Failed to send order confirmation email: " # error);      };    };  };};

Upgrading from the previous version

An app built with caffeineai-email 0.2.x re-pins with mops add [email protected]. sendServiceEmail and sendRawEmail keep their signatures; every send now carries an idempotency key, so a retried outcall is sent and charged once. Apps that use verification or marketing email follow the upgrade sections of those skills.

來源與署名

來源:caffeinelabs/skills位於skills/extension-email提交362f51a

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架