How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Send a Simple Email in Laravel (Fast SMTP + Mail::raw)
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > How to Send a Simple Email in Laravel (Fast SMTP + Mail::raw)
Web Development

How to Send a Simple Email in Laravel (Fast SMTP + Mail::raw)

how7o
By how7o
Last updated: January 12, 2026
4 Min Read
Send a simple email in Laravel using Mail::raw and SMTP
SHARE

I needed to send a “quick test email” from a Laravel project the other day. Nothing fancy—no templates, no queues, no markdown mail. Just a simple message to confirm my server could actually deliver emails.

Contents
  • What you need before sending email
  • Step 1: Configure SMTP in your Laravel .env file
  • Step 2: Send a simple email with Mail::raw()
  • Step 3 (recommended): Use a Mailable (cleaner for real projects)
  • Common errors (and how I fix them fast)
    • 1) “Connection could not be established…”
    • 2) Emails “send” but never arrive
    • 3) I changed .env but Laravel still uses old values
  • Helpful links
  • Final thoughts

But like always, the “simple” part depends on one thing: mail configuration. Laravel can send emails easily, but only after you set up SMTP in .env. Once I did that, sending the email was literally a few lines with Mail::raw().

In this guide, I’ll show you the easiest way to send a simple email in Laravel (the exact approach I use for quick testing), plus a cleaner “best practice” version using a Mailable if you decide to expand later.

What you need before sending email

  • A working Laravel project
  • SMTP credentials (Mailtrap / Gmail SMTP / SendGrid / any provider)
  • Access to edit your .env file

Step 1: Configure SMTP in your Laravel .env file

This is the part most beginners skip. Laravel won’t magically send email until you tell it which mail server to use. For testing, Mailtrap is great because it captures messages safely instead of sending them to real inboxes.

Open your .env file and add/update these values (example using Mailtrap SMTP):

MAIL_MAILER=smtp
MAIL_HOST=live.smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=<smtpuser>
MAIL_PASSWORD=<password>
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="Test User"

Important: after editing .env, clear config cache (especially on production servers where config is cached):

php artisan config:clear

If your app uses cached config in production, you can re-cache after:

php artisan config:cache

Step 2: Send a simple email with Mail::raw()

For the fastest test, I usually create a temporary route. Open routes/web.php and add this:

use Illuminate\Support\Facades\Mail;

Route::get('/test-email', function () {
    try {
        Mail::raw('This is a simple test email.', function ($message) {
            $message->to('[email protected]')
                    ->subject('Test Email');
        });

        return "Email Sent!";
    } catch (\Exception $e) {
        return $e->getMessage();
    }
});

Now visit:

https://your-domain.com/test-email

If you’re using Mailtrap, check your inbox in Mailtrap and you should see the message there.

Step 3 (recommended): Use a Mailable (cleaner for real projects)

Mail::raw() is perfect for quick testing, but if you’re building a real feature (welcome email, password reset notice, etc.), a Mailable keeps things clean.

Create a Mailable:

php artisan make:mail SimpleTestMail

Open the generated file (usually app/Mail/SimpleTestMail.php) and keep it super simple:

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SimpleTestMail extends Mailable
{
    use Queueable, SerializesModels;

    public function build()
    {
        return $this->subject('Test Email')
                    ->text('emails.simple-test');
    }
}

Create the plain text view:

// resources/views/emails/simple-test.blade.php
This is a simple test email from Laravel.

Send it from your route/controller:

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

Mail::to('[email protected]')->send(new SimpleTestMail());

Common errors (and how I fix them fast)

1) “Connection could not be established…”

  • Double-check MAIL_HOST and MAIL_PORT
  • Try switching encryption: tls (587) vs ssl (465)
  • Some VPS providers block outbound SMTP ports—Mailtrap usually works, but if not, ask your host or use an email API provider

2) Emails “send” but never arrive

  • For testing, use Mailtrap so you can verify delivery instantly
  • Make sure MAIL_FROM_ADDRESS is allowed by your SMTP provider

3) I changed .env but Laravel still uses old values

This is almost always config caching. Run:

php artisan config:clear

Helpful links

  • Laravel Mail documentation
  • Mailtrap (safe email testing)
  • Display only the current date in Laravel using Carbon

Final thoughts

If your goal is just to verify “can my Laravel app send email?”, Mail::raw() + SMTP config is the fastest path. Once it works, you can upgrade to a Mailable for cleaner code and reusable templates.

TAGGED:DebuggingEmailLaravelMail ConfigMail::rawMailableMailtrapphpSMTP

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How to force quit frozen apps in Ubuntu Force Close an App in Ubuntu (xkill, System Monitor, kill -9)
Next Article Display only the current date in Laravel using Carbon How to Display Only the Current Date in Laravel (Carbon Examples)
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Laravel Eloquent ORM — a model class mapping to a database table with query methods
Laravel Eloquent ORM: The Complete Guide to Querying Your Database
June 16, 2026
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026

You Might Also Like

WordPress wpdb get_results returns multiple rows
Web Development

How to Get Multiple Rows with $wpdb in WordPress

5 Min Read
jQuery check if a checkbox is checked
Web Development

How to Check if a Checkbox Is Checked with jQuery

4 Min Read
CSS checkbox background color — accent-color one-liner and hide-and-replace fallback
Web Development

How to Change a Checkbox Background Color with CSS

5 Min Read
Rename menu items on the WooCommerce My Account page
Web Development

How to Rename Menu Items on the WooCommerce My Account Page

4 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?