SMTP Zen Logo
Skip to main content
Published Dec 10, 2025Updated Aug 12, 2026

Laravel one-click unsubscribe: RFC 8058 code example

Add RFC 8058 List-Unsubscribe headers to a Laravel Mailable and build a secure HTTPS POST endpoint for Gmail and Yahoo.
deliverabilityrfc 8058laravelphpgmail
Laravel one-click unsubscribe: RFC 8058 code example

Laravel Mailables can add RFC 8058 headers through the underlying Symfony message. Use this pattern for marketing and subscribed messages; password resets, receipts, and other ordinary transactional messages do not require one-click unsubscribe.

Required headers

  • List-Unsubscribe: include an HTTPS endpoint; mailto can be an additional fallback.
  • List-Unsubscribe-Post: List-Unsubscribe=One-Click: tells providers to send the RFC 8058 POST.
  • Honor requests inside 48 hours; aim for immediate suppression.

Add headers inside a Mailable

Use withSymfonyMessage to set headers on the underlying Symfony Email object:

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Symfony\Component\Mime\Email;

class ProductUpdateMail extends Mailable
{
    use Queueable, SerializesModels;

    public function build()
    {
        $token = 'abcd1234'; // signed token for this recipient+list

        $this->withSymfonyMessage(function (Email $message) use ($token) {
            $message->getHeaders()
                ->addTextHeader('List-Unsubscribe', "<https://example.com/unsub/{$token}>, <mailto:[email protected]?subject=unsubscribe>")
                ->addTextHeader('List-Unsubscribe-Post', 'List-Unsubscribe=One-Click');
        });

        return $this
            ->from('[email protected]', 'Product Updates')
            ->subject('Service notice')
            ->view('emails.product-update')
            ->with(['unsubscribe_url' => "https://example.com/unsub/{$token}"]);
    }
}

Recommendations:

  • Keep a visible unsubscribe link in the blade view.
  • Accept the POST without login, cookies, or a CSRF token and return a successful response quickly.
  • Do not expose raw emails in the URL; sign the token.

Apply defaults (optional)

If you always include one-click, set a mail macro/service provider to add List-Unsubscribe-Post globally, and still inject the per-recipient List-Unsubscribe in each Mailable.

Handling the endpoint

  • Accept POST with List-Unsubscribe=One-Click; use GET only for a human-facing preference page.
  • Add the address to the token's subscription-list suppression immediately.
  • Keep essential transactional mail separate from subscription mail.
  • Log timestamp, token/list, and IP for audits.

Testing checklist

  • Send a test to Gmail/Yahoo; confirm headers in message source.
  • Click the link; verify instant suppression and 200 response.
  • Send another test within 24 hours; the unsubscribed address must not receive it.
  • Track complaint rates; keep under 0.1%.

Where SMTP Zen helps

SMTP Zen delivers your Laravel Mail output with aligned authentication. Add the headers above, wire the endpoint to your suppression logic, and you meet Gmail/Yahoo one-click expectations without a marketing ESP.

  • Pro SMTP
    High-deliverability SMTP for products at scale, unlimited domains, and priority support.
    $11.99
     /month
    Usage
    Domain Names
    Unlimited
    Mailboxes
    20
    Bandwidth
    Unlimited
    Email Forwarders / Alias
    10
    Base Disk Quota
    20GB
    Features
    Backups
    "Catch All" Emails
    Advanced Spam Filter
    SSL
    Priority Support
  • Freelancer SMTP
    Reliable, no fuss SMTP service for client work - custom domains, forwarding, and more.
    $5.99
     /month
    Usage
    Domain Names
    Unlimited
    Mailboxes
    10
    Bandwidth
    Unlimited
    Email Forwarders / Alias
    10
    Base Disk Quota
    10GB
    Features
    Backups
    "Catch All" Emails
    Advanced Spam Filter
    SSL
    Priority Support
  • Starter SMTP
    Simple, dependable SMTP to ship transactional emails - no fuss, ready in minutes.
    $2.99
     /month
    Usage
    Domain Names
    Unlimited
    Mailboxes
    5
    Bandwidth
    Unlimited
    Email Forwarders / Alias
    10
    Base Disk Quota
    5GB
    Features
    Backups
    "Catch All" Emails
    Advanced Spam Filter
    SSL
    Priority Support
  • Roll your own
    Your plan, your rules. Tailored plan just for you. Fully customizable.
    $1.2
     /month
    Usage
    Domain Names
    Unlimited
    Mailboxes
    1
    Bandwidth
    Unlimited
    Email Forwarders / Alias
    1
    Base Disk Quota
    2GB
    Features
    Backups
    "Catch All" Emails
    Advanced Spam Filter
    SSL
    Priority Support