All frameworks
Send Email from Symfony
Send emails from Symfony controllers and services
1
Install the SDK
composer require sendpigeon/sendpigeon2
Set your API key
SENDPIGEON_API_KEY=your_api_key_hereGet your API key from the dashboard.
3
Send your first email
php<?php
// src/Controller/ContactController.php
namespace App\Controller;
use SendPigeon\SendPigeon;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class ContactController extends AbstractController
{
#[Route('/contact', methods: ['POST'])]
public function contact(Request $request): JsonResponse
{
$data = json_decode($request->getContent(), true);
$client = new SendPigeon($_ENV['SENDPIGEON_API_KEY']);
$client->send(
to: $data['email'],
from: 'hello@yourdomain.com',
subject: "Thanks for reaching out, {$data['name']}!",
html: '<h1>We got your message</h1><p>We\'ll get back to you soon.</p>',
);
return $this->json(['success' => true]);
}
}Why use SendPigeon with Symfony?
- Service container integration
- Messenger async support
- Twig template support
- 99.9% deliverability with dedicated IPs
- Real-time analytics and webhook events
🧪
Testing locally? Use our local email server to catch emails without sending real ones.
🎨
Prefer visual editing? Build email templates with our free drag-and-drop builder. Learn more →
Ready to send emails from Symfony?
Start free with 3,000 emails/month. No credit card required.
Get Started Free