Prompt

How do I send emails from a Laravel app?

Technology / Api platforms1 observationLast seen Sep 23, 2026

Latest observation

Sep 23, 2026OpenAI APIWeb search: off

To send emails from a Laravel app, you typically use Laravel’s built-in Mail system, which sits on top of Symfony Mailer.

1) Configure your mail driver

Set your mail settings in .env:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME="${APP_NAME}"

Common options:

  • smtp — most common
  • mailgun, postmark, ses — for email services
  • log — writes emails to logs instead of sending
  • array — stores emails in memory for testing

2) Create a Mailable

Generate a mailable class:

php artisan make:mail WelcomeMail

This creates a class in app/Mail/WelcomeMail.php.

Example:

use Illuminate\Mail\Mailable;

class WelcomeMail extends Mailable
{
    public function build()
    {
        return $this->subject('Welcome!')
                    ->view('emails.welcome');
    }
}

3) Create the email view

Create a Blade template:

resources/views/emails/welcome.blade.php

<h1>Welcome, {{ $name }}!</h1>
<p>Thanks for joining us.</p>

If you pass data to the mailable, you can display it in the view.

Example mailable with data:

class WelcomeMail extends Mailable
{
    public function __construct(public $name) {}

    public function build()
    {
        return $this->subject('Welcome!')
                    ->view('emails.welcome');
    }
}

4) Send the email

In a controller, route, or job:

use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeMail;

Mail::to('user@example.com')->send(new WelcomeMail('John'));

5) Queue emails if needed

For better performance, you can queue emails:

Mail::to('user@example.com')->queue(new WelcomeMail('John'));

Your mailable should implement ShouldQueue if you want it queued automatically:

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;

class WelcomeMail extends Mailable implements ShouldQueue
{
    // ...
}

Then make sure your queue is configured and a worker is running.

6) Test email sending

For local development, a tool like:

  • Mailtrap
  • Mailpit
  • Mailhog

is useful so you can inspect messages without sending real emails.


If you want, I can also show you:

  1. a complete Laravel 11 example,
  2. how to send HTML emails, or
  3. how to use queue jobs for email sending.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as Circuit. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.