Skip to content

secondsky/claude-skills / plugins/cloudflare-email-routing/skills/cloudflare-email-routing

cloudflare-email-routing

Unverified

Cloudflare Email Routing for receiving/sending emails via Workers. Use for email workers, forwarding, allowlists, or encountering Email Trigger errors, worker call failures, SPF issues.

templates/send-basic.ts

View on GitHub
/**
 * Send Email - Basic Example
 *
 * This Worker demonstrates sending emails using the send_email binding.
 *
 * Prerequisites:
 * 1. Email Routing enabled on your domain
 * 2. Destination address verified in Email Routing settings
 * 3. send_email binding configured in wrangler.jsonc:
 *
 *    "send_email": [
 *      {
 *        "name": "EMAIL",
 *        "destination_address": "notifications@yourdomain.com"
 *      }
 *    ]
 *
 * To use:
 * 1. Install dependencies: npm install mimetext
 * 2. Configure wrangler.jsonc with send_email binding
 * 3. Deploy: npx wrangler deploy
 * 4. Visit worker URL or trigger via fetch()
 */

import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

interface Env {
  // Send email binding (configured in wrangler.jsonc)
  EMAIL: {
    send(message: EmailMessage): Promise<void>;
  };
}

export default {
  async fetch(request: Request, env: Env, ctx): Promise<Response> {
    try {
      // Create email message
      const msg = createMimeMessage();

      // Set sender (must be from your domain with Email Routing enabled)
      msg.setSender({
        name: 'My Application',
        addr: 'noreply@yourdomain.com',
      });

      // Set recipient
      msg.setRecipient('user@example.com');

      // Set subject
      msg.setSubject('Welcome to My Application');

      // Add plain text message
      msg.addMessage({
        contentType: 'text/plain',
        data: 'Thank you for signing up! We are excited to have you on board.',
      });

      // Optional: Add HTML version
      msg.addMessage({
        contentType: 'text/html',
        data: '<h1>Welcome!</h1><p>Thank you for signing up!</p>',
      });

      // Create EmailMessage and send
      const emailMessage = new EmailMessage(
        'noreply@yourdomain.com',
        'user@example.com',
        msg.asRaw()
      );

      await env.EMAIL.send(emailMessage);

      return new Response('Email sent successfully!', { status: 200 });
    } catch (error) {
      console.error('Error sending email:', error);
      return new Response('Failed to send email', { status: 500 });
    }
  },
};
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall