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 从公开仓库中收录这些内容。

举报或申请下架