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.
- 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
.envfile
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:clearIf your app uses cached config in production, you can re-cache after:
php artisan config:cacheStep 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-emailIf 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 SimpleTestMailOpen 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_HOSTandMAIL_PORT - Try switching encryption:
tls(587) vsssl(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_ADDRESSis 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:clearHelpful 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.
