extension-email
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.
module {
public type SendResult = {
#ok;
#err : Text;
};
public func sendServiceEmail(
fromUsername : Text,
recipients : [Text],
subject : Text,
htmlBody : Text,
) : async SendResult;
};
Usage for sendServiceEmail:
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);
};
};
};
};
More from caffeinelabs/skills
extension-email-calendar-events
Support for organising events/meetings and sending invitations by email.
28extension-qr-code
QR code scanner using the camera.
24extension-core-infrastructure
Core infrastructure providing backend connection configuration, storage client, and React app entry point.
23extension-email-marketing
Send personalised marketing emails to subscribers with an unsubscribe link.
23extension-email-verification
Support for sending an email with a link the recipient can click to prove they own the email address.
23extension-object-storage
General file/object storage, such as for images, videos, files, documents and other bulk data. Perfect fit for image galleries, video galleries, and other file or object management. Supports large files beyond IC limit, with browser-cached HTTP URL access.
23