All guides
Send Email from Laravel
Send emails from Laravel controllers and jobs
1. Install the SDK
composer require sendpigeon/sendpigeon2. Set your API key
Add your SendPigeon API key to your environment variables:
SENDPIGEON_API_KEY=your_api_key_hereGet your API key from the dashboard.
3. Send your first email
<?php
// app/Http/Controllers/ContactController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use SendPigeon\SendPigeon;
class ContactController extends Controller
{
public function store(Request $request)
{
$validated = $request->validate([
'email' => 'required|email',
'name' => 'required|string',
]);
$client = new SendPigeon(config('services.sendpigeon.key'));
$client->send(
to: $validated['email'],
from: 'hello@yourdomain.com',
subject: "Thanks for reaching out, {$validated['name']}!",
html: '<h1>We got your message</h1><p>We\'ll get back to you soon.</p>',
);
return response()->json(['success' => true]);
}
}Features
- Works with Laravel queues
- Notification channel support
- Blade template integration
Ready to send emails?
Get started with 1,000 free emails per month.
Start for free