Communityコーディング&開発github.com

Taldres/laravel-waitlist: メール送信

taldres/laravel-waitlist インテグレーションのメール(ダブルオプトイン確認、設定ページリンク、ウェルカムメール、ローンチメール、ニュースレター)を、同意したユーザーに正しい配信停止リンク、ワンクリックヘッダー、プロジェクトごとの送信者で送信します。

laravel-waitlist: メール送信 とは?

このスキルは、Laravel アプリケーションで `taldres/laravel-waitlist` パッケージを使用して、待機リスト(ウェイトリスト)に関連するメール送信を実装するためのものです。パッケージ自体はイベントを発行するだけで、実際のメール送信はアプリケーションのリスナーが担当します。このスキルは、ダブルオプトイン確認メール、設定ページリンク、ウェルカムメール、ローンチメール、ニュースレターの5種類のメールを、それぞれの目的に応じた正しいリンクとヘッダーを付けて送信する方法を提供します。Laravel のキュー、暗号化リスナー、ワンクリック配信停止ヘッダー(RFC 8058)を利用して、同意の有効なアドレスのみに送信し、プロジェクトごとに異なる送信者とメーラーを設定できます。主な対応メールプロバイダは Resend、Postmark、SES、SMTP など、Laravel のメーラーでサポートされるものです。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Taldres/laravel-waitlist/tree/HEAD/resources/boost/skills/laravel-waitlist-mail

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Laravel Waitlist: メール送信

このスキルは、taldres/laravel-waitlist を使用するアプリケーションが、待機リストに登録しているユーザーにメールを送信したり、そのためのメールプロバイダを設定する必要がある場合に使用します。

主な目的

  • フローで必要なすべてのメールが、キュー処理され暗号化されたリスナーから送信され、その目的に合ったリンクを保持し、同意が有効なアドレスにのみ到達すること。

ワークフロー

1. どのメールがいつ送られるべきかを把握する

このパッケージはメールを送信せず、プロバイダも呼び出しません。イベントを発火し、アプリケーションのリスナーが任意の Laravel メーラー(Resend、Postmark、SES、SMTP など)を使用して送信します。

メール送信タイミング必須リンク
確認メール(ダブルオプトイン)EntrySubscribed かつ $event->requiresConfirmation$event->confirmUrl、$event->unsubscribeUrl
設定ページリンクManageLinkRequested$event->manageUrl、$event->entry->email のみに送信
ウェルカムメール(オプション)EntryConfirmed$event->unsubscribeUrl、Waitlist::listUnsubscribeHeaders($event->entry)
特定のリストに関するローンチまたはアップデートメールアプリが決定リストから退会するための受信者ごとのリンク
ニュースレター(オプション目的)アプリが決定ニュースレターのみを解除するための受信者ごとのリンク

2. 確認メール用リスナー

namespace App\Listeners;

use App\Mail\ConfirmWaitlistMail;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Mail;
use LogicException;
use Taldres\Waitlist\Events\EntrySubscribed;
use Taldres\Waitlist\Facades\Waitlist;

class SendWaitlistConfirmationMail implements ShouldQueue, ShouldBeEncrypted
{
    public function handle(EntrySubscribed $event): void
    {
        if (! $event->requiresConfirmation) {
            return;
        }

        $confirmUrl = $event->confirmUrl ?? throw new LogicException('確認ページを urls() で設定するか、パッケージのルートを有効にしてください。');

        Mail::to($event->entry->email)->send(new ConfirmWaitlistMail(
            $confirmUrl,
            $event->unsubscribeUrl,
            $event->subscription->consents->pluck('text')->all(), // 確認中の内容
        ));

        Waitlist::confirmationMailed($event->subscription, 'confirm-mail@2026-10');
    }
}
  • 同じイベントが再送信の場合も含みます($event->isNewCycle === false)。リスナー内でスロットル制御をしないでください。パッケージのクールダウンと上限ですでに処理済みです。
  • confirmationMailed() は同意の横にメールの参照を記録します。テンプレート名とバージョンを使用し、各バージョンのテキストを保持してください。
  • $event->confirmUrl は、プロジェクトの urls() が confirm ページを設定しておらず、パッケージルートがオフの場合に null になります。構築できないリンク(ルートはオンだが登録されていない場合、例えば古いルートキャッシュの後など)は InvalidConfigurationException をスローし、サインアップまたは確認を取り消します。何もコミットされないため、イベントは発火せず、メール送信も発生しません。

3. 設定ページリンク用リスナー

use Taldres\Waitlist\Events\ManageLinkRequested;

class SendManageLinkMail implements ShouldQueue, ShouldBeEncrypted
{
    public function handle(ManageLinkRequested $event): void
    {
        Mail::to($event->entry->email)->send(new ManageLinkMail($event->manageUrl, $event->expiresAt));
    }
}

リンクの有効期限は waitlist.manage.token_ttl 分(デフォルト60分)です。メール内でその旨を記載してください。

4. ローンチメールとニュースレター:recipients() を使用

use Taldres\Waitlist\Support\Recipient;

// 1つのリスト、そのプライマリ目的向け:リンクはそのリストから退会
Waitlist::for('beta')->recipients()->each(
    fn (Recipient $recipient) => Mail::to($recipient->email)->locale($recipient->locale)->queue(new LaunchMail($recipient)),
);

// オプションの目的、プロジェクト全体、アドレスごとに1回:リンクはその目的のみを解除
Waitlist::recipients('newsletter')->each(
    fn (Recipient $recipient) => Mail::to($recipient->email)->locale($recipient->locale)->queue(new NewsletterMail($recipient)),
);

Mailable 内で、受信者のリンクを使用します:

use Illuminate\Mail\Mailables\Headers;

public function __construct(public Recipient $recipient) {}

public function headers(): Headers
{
    return new Headers(text: $this->recipient->listUnsubscribeHeaders()); // RFC 8058 ワンクリック
}

// コンテンツ内: $this->recipient->unsubscribeUrl()

Recipient は entry、email、purpose、locale(同意の言語、または null)、leavesList を持ちます。キュー投入された Mailable はアドレスとトークンリンクを保持するため、これらも ShouldBeEncrypted を実装するようにしてください。ワンクリックヘッダーを使用するには、パッケージルートと https の APP_URL が必要です。ルートがない場合は空になります。

5. イベント外でのリンク生成

Waitlist::unsubscribeUrl($entry);                // リストから退会
Waitlist::unsubscribeUrl($entry, 'newsletter');  // ニュースレターのみ解除
Waitlist::listUnsubscribeHeaders($entry, 'newsletter');

6. 複数プロジェクト対応

プロジェクトは $event->entry->project(または $recipient->entry->project)で取得します。そこから送信者とメーラーを選択します:

// config/products.php(アプリケーション独自): ['rocket' => ['name' => 'Rocket', 'from' => '[email protected]', 'mailer' => 'resend'], ...]
$product = config("products.{$event->entry->project}");

$mail = (new ConfirmWaitlistMail(...))->from($product['from'], $product['name']);
Mail::mailer($product['mailer'])->to($event->entry->email)->send($mail);

メール内のリンクは、各プロジェクト自身のページを指しています(urls())。

ルール、参考、テンプレート

  • メールを送信するすべてのリスナーは、ShouldQueue(新規アドレスと既存アドレスで応答時間を同一にするため)と ShouldBeEncrypted(ペイロードにトークンを含むため、EntryForgotten はアドレスを含む)を実装します。
  • Laravel は app/Listeners 内のリスナーを handle() の型ヒントによって自動発見します。Event::listen() で再度登録すると、すべてのメールが2回送信されます。
  • イベントはコミット後にディスパッチされます。ディスパッチされたイベントはメールが送信されたことを保証しません。そのため、失敗したジョブを監視してください。
  • メールドライバの設定:https://laravel.com/docs/mail。SPF、DKIM、DMARC を設定したドメインから送信してください。
  • 完全ガイド:https://github.com/Taldres/laravel-waitlist/blob/main/docs/mail.md

例

  • 「Resend でダブルオプトインメールを送信する」:composer require resend/resend-php、MAIL_MAILER=resend、RESEND_KEY=... を設定後、手順2のリスナーを使用。
  • 「ベータリストの全員にローンチメールを送信する」:手順4で Waitlist::for('beta')->recipients() を使用。
  • 「毎月のニュースレターを送信する」:Waitlist::recipients('newsletter') を使用し、受信者ごとにワンクリックヘッダーを付与。

アンチパターン

  • 同意チェックなしで WaitlistEntry::all() や Waitlist::for($list)->entries() にメールを送信すること。代わりに recipients() または whereConsentedTo($purpose) を使用してください。
  • 通常のメールに Waitlist::manageLink($entry) や管理URL を含めること。相手のデータが開示され、メールが転送される可能性があります。
  • 管理リンクを $event->entry->email 以外のアドレスに送信すること、またはそのリクエストに管理リンクで応答すること。
  • ニュースレターのリンクでリスト全体から退会させること。代わりに unsubscribeUrl($entry, 'newsletter') または Recipient のリンクを使用してください。
  • 同期メールリスナー、または ShouldBeEncrypted なしのキューリスナーを使用すること。

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

Taldres/laravel-waitlist

Use this skill when reviewing Laravel package compatibility across composer constraints, PHP versions, Laravel versions, Testbench versions, dependency stability lanes, Windows CI, or matrix-sensitive code and workflow changes.

Taldres/laravel-waitlist

Use this skill when creating or updating the bundled Laravel Boost skill under resources/boost/skills from the package implementation and package documentation. Trigger after public APIs, commands, config, routes, views, publish tags, README content, or examples change.

Taldres/laravel-waitlist

Use this skill when preparing Laravel package releases: CHANGELOG.md updates, generated release notes, GitHub release workflows, version checks, tags, release validation, or release automation changes. Never publish autonomously.

Taldres/laravel-waitlist

Use this skill when adding Laravel package capabilities or wiring them through the service provider: commands, migrations, routes, config merges, views, translations, assets, middleware, publish tags, workbench files, or console-only behavior.

Taldres/laravel-waitlist

Use this skill when writing, editing, fixing, or reviewing package tests with Pest 4/5 and Orchestra Testbench, including TDD, feature tests, unit tests, type coverage, arch tests, workbench behavior, commands, routes, config, migrations, and publishable resources.

Taldres/laravel-waitlist

Integrate taldres/laravel-waitlist in a Laravel application: define purposes, lists and fields, build the signup form, send the confirmation mail from events, add a preference page, and keep consent, retention and encryption intact.

Taldres/laravel-waitlist

Build the pages of a taldres/laravel-waitlist integration: the signup form with the registered wording, and the confirm, unsubscribe and preference pages, either in Laravel controllers (Blade, Livewire, Inertia) or in an SPA or static site over the package's JSON API, including CORS and bot protection.

Taldres/laravel-waitlist

Turn a taldres/laravel-waitlist waitlist into a launch: invite people in batches in signup order, let invited addresses register, announce the launch to everyone who agreed, and erase the list once its purpose is fulfilled.

Taldres/laravel-waitlist

Operate a taldres/laravel-waitlist installation: answer access and erasure requests, withdraw a purpose on request, apply retention, erase a list once its purpose is fulfilled, rotate APP_KEY with waitlist:rekey, export a list, and check the setup before going live.

Taldres/laravel-waitlist

Run the waitlists of several products in one Laravel app with taldres/laravel-waitlist projects: define projects, scope facade calls with project(), resolve the project of HTTP signups, send mail per project, handle requests across all projects, or keep projects in a database for a central waitlist API.

Taldres/laravel-waitlist

Keep a newsletter tool such as Brevo, Mailchimp or Mailcoach in step with a taldres/laravel-waitlist waitlist: add confirmed contacts per purpose, remove them on withdrawal and erasure, and carry unsubscribes made at the provider back into the waitlist via a webhook.

Taldres/laravel-waitlist

Build waitlist statistics with taldres/laravel-waitlist: signups and confirmations per day for charts, totals and confirmation rates for a period, the confirmed count on any past day, and how many people are on a list right now, for dashboards, admin pages and API endpoints.

Taldres/laravel-waitlist

Write feature tests for an application's taldres/laravel-waitlist integration: get the plain tokens from events, assert the confirmation and other mails, test the signup, confirm and unsubscribe flows in PHP and over the package's HTTP routes, and bypass rate limits and bot checks in tests.

関連スキル