Prevent Auto-Responders on Your Application Emails

When sending emails you might trigger unwanted auto-responders. You can blackhole all responses or add two headers to suppress them instead.

Alex Bouma

Alex Bouma

Founder Chief Tools

Ideally the Reply-To address for emails your application sends is linked to your support email so customers can easily reach you. The downside is the endless flow of auto-responders that might be triggered by this. It's nice to know when someone is on vacation but maybe not if you send them a weekly report or other email from your application. There is luckily an easy fix so you don't have to resort to a noreply@example.com reply-to address.

The following headers will silence most (probably not all, we all know how mail providers are) auto-responders. The first header (Auto-submitted) is part of RFC 3834 "Recommendations for Automatic Responses to Electronic Mail" and the second (X-Auto-Response-Suppress) is there for Microsoft because of course we have to handle them a little more special.

1Auto-submitted: auto-generated
2X-Auto-Response-Suppress: OOF, AutoReply

In Laravel you can wire up the Illuminate\Mail\Events\MessageSending event to easily add these headers by default:

1<?php
2
3namespace App\Listeners\Mail;
4
5use Illuminate\Mail\Events\MessageSending;
6
7class PreventAutoResponders
8{
9 public function handle(MessageSending $event): void
10 {
11 $headers = $event->message->getHeaders();
12
13 $headers->addTextHeader('Auto-submitted', 'auto-generated');
14 $headers->addTextHeader('X-Auto-Response-Suppress', 'OOF, AutoReply');
15 }
16}

And in your AppServiceProvider:

1 public function boot(): void
2 {
3 \Illuminate\Support\Facades\Event::listen(
4 \Illuminate\Mail\Events\MessageSending::class,
5 \App\Listeners\Mail\PreventAutoResponders::class,
6 );
7 }

Enjoy the quiet support inbox, and unlike a noreply@ address, customers can still reach you when it actually matters.

Need help?

We are happy to help you with any questions you might have.

  Documentation   Roadmap   Report a bug   Get in touch