본문으로 건너뛰기
cccskills
무료GitHub에 공개

laravel-mail

Use when building Laravel emails — Mailables, Markdown templates, queued sending, attachments, previews — even when the user says 'send this as an email' without naming Mailables.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구GmailOutlook
설치 방법 보기

포함된 파일(1)

  • SKILL.md8.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

laravel-mail

When to use

Use this skill when building email functionality:

  • Mailable classes with HTML/Blade or Markdown templates
  • Queued email sending
  • Attachments and inline images
  • Mail testing and previewing

For simple notification emails (one-off messages), see laravel-notifications. Use Mailables when you need full control over the email template.

Procedure: Create a Mailable

  1. Inspect existing mailables — Review app/Mail/ for naming, base class, queueing convention, and the templates in resources/views/emails/ for the project's markdown style.
  2. Generate class — php artisan make:mail InvoiceMail --markdown=emails.invoice.
  3. Configure — Set subject, from, attachments, queuing (ShouldQueue).
  4. Create template — Markdown template in resources/views/emails/.
  5. Verify — Send test email, confirm rendering and delivery.

Example

php artisan make:mail InvoiceMail --markdown=emails.invoice
declare(strict_types=1);

namespace App\Mail;

use App\Models\Invoice;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class InvoiceMail extends Mailable implements ShouldQueue
{
    use Queueable;
    use SerializesModels;

    public function __construct(
        private readonly Invoice $invoice,
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Invoice #' . $this->invoice->getNumber(),
            replyTo: ['billing@example.com'],
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'emails.invoice',
            with: [
                'invoice' => $this->invoice,
                'url' => route('invoices.show', $this->invoice->getId()),
            ],
        );
    }

    /** @return array<int, \Illuminate\Mail\Mailables\Attachment> */
    public function attachments(): array
    {
        return [
            Attachment::fromPath('/path/to/invoice.pdf')
                ->as('invoice-' . $this->invoice->getNumber() . '.pdf')
                ->withMime('application/pdf'),
        ];
    }
}

Markdown templates

{{-- resources/views/emails/invoice.blade.php --}}
<x-mail::message>
# Invoice {{ $invoice->getNumber() }}

Thank you for your order. Here is your invoice summary:

<x-mail::table>
| Item | Amount |
|:-----|-------:|
@foreach ($invoice->getItems() as $item)
| {{ $item->getName() }} | {{ $item->getFormattedAmount() }} |
@endforeach
| **Total** | **{{ $invoice->getFormattedTotal() }}** |
</x-mail::table>

<x-mail::button :url="$url">
View Invoice
</x-mail::button>

Thanks,<br>
{{ config('app.name') }}
</x-mail::message>

Sending mail

// Send immediately
Mail::to($user)->send(new InvoiceMail($invoice));

// Queue for background sending (preferred)
Mail::to($user)->queue(new InvoiceMail($invoice));

// Send later
Mail::to($user)->later(now()->addMinutes(10), new InvoiceMail($invoice));

// Multiple recipients
Mail::to($users)
    ->cc($manager)
    ->bcc('archive@example.com')
    ->send(new InvoiceMail($invoice));

Testing

// Assert mail was sent
Mail::fake();

// ... trigger action ...

Mail::assertSent(InvoiceMail::class, function (InvoiceMail $mail) use ($user) {
    return $mail->hasTo($user->getEmail());
});

Mail::assertNotSent(InvoiceMail::class);
Mail::assertNothingSent();
Mail::assertQueued(InvoiceMail::class);

Previewing in browser

// routes/web.php (local only)
Route::get('/mail-preview', function () {
    $invoice = Invoice::factory()->create();
    return new InvoiceMail($invoice);
});

Surviving the mail client

An email is not a web page. Mail clients strip, rewrite, and ignore CSS that every browser honors, so a template that renders correctly in /mail-preview tells you nothing about the inbox. Markdown templates (above) give you a tested baseline for free — this section is what to hold to when a design forces you off them.

Four requirements, in order of what breaks first:

  1. Table-based layout, not flexbox or grid. Use nested <table> elements with role="presentation", a fixed outer width of 600px, and cellpadding / cellspacing / border set to 0. display: flex and display: grid are unsupported or partially supported in the Windows Outlook family and collapse to a single stacked column.
  2. Inline styles, not a <style> block. Write style="…" on the element. A <head><style> block is stripped outright by some webmail clients, and class selectors then match nothing. Use a CSS inliner at build time if the template is authored with classes — never ship the classes unresolved. Keep a <style> block only for what cannot be inlined (media queries), and treat everything in it as optional.
  3. No web fonts, no background images, no external JS. Declare a font stack ending in a system fallback; a remote font silently degrades. Background images require the v:fill VML fallback in Outlook, so put the color on bgcolor and treat the image as decoration.
  4. Explicit width and alt text on every image, and no image-only content. Images are blocked by default in several clients, so an email whose call to action is an image is an email with no call to action.

The client list worth testing, and what breaks in each:

ClientWhat breaks
Outlook 2016-2019 / Windows (Word engine)flex, grid, float, max-width, border-radius, background images, padding on <div>; the strictest target — if it renders, most others do
Outlook.com / Outlook 365 webstrips <style> blocks in some views; rewrites class attributes; ignores margin on several elements
Gmail webclips the message past ~102 KB of HTML with a "view entire message" link — anything below the clip, including the unsubscribe link, is not seen; strips <style> when the message is clipped
Gmail app (iOS / Android)no support for embedded <style> on non-Gmail accounts; media queries ignored there, so the mobile layout must be the fluid default
Apple Mail / iOS Mailthe most permissive; auto-scales small text and auto-links dates and addresses unless suppressed — a false green if it is the only client you check
Dark mode (Apple Mail, Outlook, Gmail)colors are force-inverted; a logo on a hardcoded white background becomes a white box on dark, and #000 text on a transparent background becomes invisible

Verify against a real client, not a preview route. /mail-preview renders in a browser and proves none of the above. Send to real accounts, or use a rendering service, before the template ships.

Core rules

  • Always queue emails — implement ShouldQueue to avoid blocking requests.
  • Use Markdown templates for consistent styling across email clients.
  • Use Envelope + Content pattern (Laravel 11+) — not the old build() method.
  • Test with Mail::fake() — verify recipients, content, and queuing.
  • Keep Mailables focused — one Mailable per email type.

Output format

  1. Mailable class with envelope, content, and attachments
  2. Blade/Markdown email template
  3. Queued mail dispatch integration

Auto-trigger keywords

  • Mailable
  • email template
  • send mail
  • Mail::to
  • markdown email
  • mail attachment

Gotcha

  • Always queue emails (ShouldQueue) — synchronous sending blocks the request.
  • The model forgets that mail templates are Blade files — they need to be published/created.
  • Don't test email content with Mail::fake() alone — it doesn't render the template. Use Mail::assertSent() with closure.

Do NOT

  • Do NOT send emails synchronously in request lifecycle — always queue.
  • Do NOT use build() method — use envelope(), content(), attachments().
  • Do NOT hardcode email addresses — use config or environment variables.
  • Do NOT put HTML in Mailable classes — use Blade templates.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when reviewing UI for accessibility — WCAG 2.2 AA, keyboard nav, focus, ARIA, contrast, screen-reader semantics — even on 'is this a11y-OK?' or 'mach das barrierefrei'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config132026년 10월 22일 업데이트

Use when defining or auditing the activation event — aha-moment selection, retention correlation, falsifiable definition. Triggers on 'what is our aha moment', 'redefine activation'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config132026년 10월 22일 업데이트

Use when capturing an architectural decision — file naming, next ADR number, Status / Context / Decision / Consequences, index regen; fires even without saying 'ADR'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config132026년 10월 22일 업데이트

Adversarial critique — devil's advocate, stress-test, honest teardown ('poke holes', 'be brutal', 'was hältst du davon'); explicit request only. Routine code or design review → code-review.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config132026년 10월 22일 업데이트

Use when reading, creating, or updating agent documentation, module docs, roadmaps, or AGENTS.md. Understands the full .augment/, agents/, and copilot-instructions structure.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config132026년 10월 22일 업데이트

Use for an adversarial red-team / blue-team / auditor review of an AI agent's CONFIG + behaviour (rules, skills, MCP, hooks, permissions) — attack-chain → defensive-gap list, not a code audit.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

event4u-app/agent-config132026년 10월 22일 업데이트

event4u-app의 스킬 모두 보기

이 스킬의 문제 신고