claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdeployment

📧email

プラグイン
valtown

説明

次のような場合に使用: valがメールを送信する、メールを受信する、または受信メールによってトリガーされる場合。 メール型val(Emailハンドラーの形式、添付ファイルの制限、valに割り当てられたメールアドレス)および `std/email` を介したメール送信をカバーします。

原文を表示

Use when a val sends email, receives email, or is triggered by an incoming email. Covers email-type vals (the Email handler shape, attachment limits, the assigned val email address) and sending mail via std/email.

ユースケース

  • メールを送信する場合
  • メールを受信する場合
  • 受信メールによってトリガーされる場合

本文(日本語訳)

メール

Val Town は双方向のメール操作に対応しています。val は受信メールによってトリガーされること(email タイプの val)も、std/email を使ってメールを送信することも可能です。


メールの受信 — email タイプの val

email val(fileType: "email")は、その val に割り当てられたアドレスにメッセージが届いたときに実行されます。

// Learn more: https://docs.val.town/vals/email/
// Email type: {
//   from: string,
//   to: string[],
//   subject?: string,
//   text?: string,
//   html?: string,
//   attachments: File[],
//   headers: Record<string, string>
// }
export default async function (e: Email) {
  console.log(e.from, e.subject, e.text);
}

ファイルには必ず export が必要です。ハンドラには export default を使用してください。

メッセージ 1 通あたりの上限は 30MB(添付ファイル含む)。 上限を超えたメッセージは受信拒否されます。

割り当てアドレスの読み取り

ファイルの一覧取得または email タイプのファイル作成時、レスポンスには links.email が含まれます。これがこの val をトリガーするメールアドレスです。 このアドレスは必ず API レスポンスから読み取ってください。アドレスを自前で組み立てることは絶対に避けてください — アドレスのフォーマットはプラットフォーム側が管理しており、変更される可能性があります。


メールの送信 — std/email

送信には std/email からインポートします:

import { email } from "https://esm.town/v/std/email";

await email({
  to: "user@example.com",
  subject: "Hello",
  text: "Message body",
});

std/email は送信関数そのものを email としてエクスポートしています。 email({ ... }) のように直接呼び出してください。email.send というメソッドは存在しません。

受け付けるフィールドは tosubjecttexthtml のほか、fromccbccreplyToattachmentsheaders です。 to を指定しない場合は、val オーナーのアドレスへの送信がデフォルト動作となります。


受信メッセージへの返信

受信と送信を組み合わせることで返信が可能です。 email タイプのハンドラ内で受信メールの from を読み取り、email 関数で返信します:

import { email } from "https://esm.town/v/std/email";

export default async function (e: Email) {
  await email({
    to: e.from,
    subject: `Re: ${e.subject ?? ""}`,
    text: "Got it, thanks!",
  });
}

変更の確認

email タイプの val を編集した後は、実際のメール受信を待つ代わりに、run_file にサンプルの Email ペイロードを渡してハンドラを手動で呼び出してください。 送信専用の val については、同様にスクリプトを実行し、get_logs で配信エラーが出ていないか確認してください。

原文(English)を表示

Email

Val Town supports both directions: vals can be triggered by incoming mail (email-type vals) and can send mail via std/email.

Receiving email — email-type vals

Email vals (fileType: "email") run when a message is delivered to the val's assigned address.

// Learn more: https://docs.val.town/vals/email/
// Email type: {
//   from: string,
//   to: string[],
//   subject?: string,
//   text?: string,
//   html?: string,
//   attachments: File[],
//   headers: Record<string, string>
// }
export default async function (e: Email) {
  console.log(e.from, e.subject, e.text);
}

The file must have an exportexport default for the handler.

Maximum 30MB per message, including attachments. Larger messages will be rejected.

Reading the assigned address

When you list files or create an email-type file, the response includes links.email — the address that triggers this val. Always read this from the API response. Never construct an email address yourself — the format is owned by the platform and may change.

Sending email — std/email

For outgoing mail, import from std/email:

import { email } from "https://esm.town/v/std/email";

await email({
  to: "user@example.com",
  subject: "Hello",
  text: "Message body",
});

std/email exports email as the send function itself — call it directly (email({ ... })); there is no email.send method. It accepts the shape you'd expect: to, subject, text, html, plus from, cc, bcc, replyTo, attachments, and headers. If no to field is specified, it defaults to sending mail to the val owner's address.

Replying to an incoming message

Combine the two — read the inbound from in an email-type handler, then call email to reply:

import { email } from "https://esm.town/v/std/email";

export default async function (e: Email) {
  await email({
    to: e.from,
    subject: `Re: ${e.subject ?? ""}`,
    text: "Got it, thanks!",
  });
}

Verifying changes

After editing an email-type val, use run_file with a sample Email payload to invoke the handler manually instead of waiting for a real incoming message. For send-only vals, run the script the same way and check get_logs for delivery errors.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。