Lightweight setup & reliable delivery
Add email sending to your Slim Framework app in minutes with Sidemail's official PHP SDK and developer‑friendly API. Sidemail takes care of deliverability, SPF/DKIM/DMARC, email layout, and infrastructure so your Slim routes can send reliable, production‑ready emails with minimal code.
Get startedRead API docsuse Sidemail\Sidemail;
$app->post('/register', function (Request $request, Response $response) {
$data = $request->getParsedBody();
$sidemail = $this->get(Sidemail::class);
$sidemail->sendEmail([
'toAddress' => $data['email'],
'fromAddress' => '[email protected]',
'fromName' => 'Your App',
'templateName' => 'Welcome',
'templateProps' => ['firstName' => $data['name']],
]);
$response->getBody()->write('User registered');
return $response;
});Start sending emails from your Slim app in three steps:
Add Sidemail to your Slim project via Composer:
composer require sidemail/sidemailRegister the Sidemail client in your DI container (e.g. PHP-DI). The SDK reads SIDEMAIL_API_KEY from your environment automatically.
// app/dependencies.php
use Sidemail\Sidemail;
use Psr\Container\ContainerInterface;
return function (ContainerInterface $container) {
$container->set(Sidemail::class, function () {
return new Sidemail();
});
};Retrieve the Sidemail instance from the container and call sendEmail. Pass the recipient, sender, and template or content. That's it.
$app->post('/register', function (Request $request, Response $response) {
$data = $request->getParsedBody();
$sidemail = $this->get(Sidemail::class);
$sidemail->sendEmail([
'toAddress' => $data['email'],
'fromAddress' => '[email protected]',
'fromName' => 'Your App',
'templateName' => 'Welcome',
'templateProps' => ['firstName' => $data['name']],
]);
$response->getBody()->write('User registered');
return $response;
});Key features & perks
With Sidemail, you can send any transactional email from Slim. Here are a few examples with code:
// Slim: Send an account verification email
$app->post('/register', function (Request $request, Response $response) {
$data = $request->getParsedBody();
$sidemail = $this->get(Sidemail::class);
$sidemail->sendEmail([
'toAddress' => $data['email'],
'fromAddress' => '[email protected]',
'fromName' => 'Your App',
'templateName' => 'Email Verification',
'templateProps' => [
'verifyUrl' => 'https://yourapp.com/verify?token=' . $token,
],
]);
$response->getBody()->write('User registered');
return $response;
});Send a sign-up verification email with a one-time link or code to confirm the user's address.
// Slim: Send a payment receipt email
$sidemail->sendEmail([
'toAddress' => $user['email'],
'fromAddress' => '[email protected]',
'fromName' => 'Your App',
'templateName' => 'Payment Receipt',
'templateProps' => [
'userName' => $user['name'],
'amount' => '$19.99',
'date' => date('M j, Y'),
],
]);Send a receipt, invoice, or generic notification to your user.
templateProps to populate the template.// Slim: Schedule a welcome email for 1 hour from now
$sidemail->sendEmail([
'toAddress' => '[email protected]',
'fromAddress' => '[email protected]',
'fromName' => 'Your App',
'templateName' => 'Welcome',
'templateProps' => ['firstName' => 'Alex'],
'scheduledAt' => (new DateTime('+1 hour'))->format(DateTime::ATOM),
]);Schedule a welcome email to be sent later, for example one hour after sign-up.
scheduledAt field with an ISO timestamp to control exactly when the email is sent.// Slim: Send a password reset email with Markdown
$markdown = file_get_contents(
__DIR__ . '/../templates/emails/password-reset.md'
);
$sidemail->sendEmail([
'toAddress' => '[email protected]',
'markdown' => $markdown,
'templateProps' => [
'firstName' => 'Alex',
'resetLink' => 'https://yourapp.com/reset?token=abc123xyz',
'expiresIn' => '30 minutes',
],
]);---
subject: "Reset your password"
fromAddress: "[email protected]"
fromName: "Your App Security"
---
Hi {firstName}, we received a request to reset your password.
[$btn Reset password]({resetLink})
This link expires in {expiresIn}.Sidemail's API gives you an option to write email content in Markdown, which is automatically transformed into pixel‑perfect, responsive emails that look great in every inbox and on every device. Each email is branded with your logo and styled to match your project's email design.
.md filetemplateProps(such as resetLink and expiresIn), which map directly to variables in your markdown.Deliverability best practices
SPF and DKIM are authentication protocols that verify your emails are legitimately sent from your domain. And DMARC builds on both by instructing mail servers how to handle messages that fail those checks. Together, they are 3 critical factors for inbox delivery and sender reputation.
Sidemail automatically handles SPF, DKIM, and DMARC setup for you, so your Slim app sends authenticated, best‑practice‑compliant emails from day one.




The simplest way to build emails
Sidemail's no‑code email editor is the easiest way to create responsive email templates that render correctly across every client and device. No HTML knowledge required. Add your logo and brand colors, and you're ready to send.
Need to move even faster? Sidemail has a library of production‑ready templates for the most common use cases – password resets, welcome emails, receipts, and more. Whether you're building from scratch or customizing a premade template, we guarantee your emails look great everywhere.
Learn moreDeveloper‑friendly formatting
Writing and maintaining HTML emails by hand is tedious, especially when you just want to send clean, readable content.
Sidemail lets you write your email body in Markdown and automatically converts it into a responsive, well‑styled HTML email. You get smart formatting, like headings, lists, links, and code blocks, without worrying about broken layouts or cross‑client rendering issues.
Ideal for transactional emails generated from your Slim app – clean content, fast authoring, and zero HTML to debug.
Learn more
Ready to send transactional emails from your Slim app? With Sidemail's API and premade templates, you can integrate in minutes and deliver emails reliably.
Start free trialThe easiest way to send email from a Slim app is by using an email API like Sidemail. Install the PHP SDK (composer require sidemail/sidemail), register the client in your DI container, and call $sidemail->sendEmail() inside any route handler. No SMTP setup or complex configuration needed. Sidemail handles authentication, formatting, and deliverability for you.
Yes. Sidemail's PHP SDK is a plain PHP class that works with any PSR-compliant setup. Register it in your DI container (like PHP-DI) and resolve it in route handlers with $this->get(Sidemail::class). It fits naturally into Slim's lightweight, standards-based architecture.
Instead of building email HTML in your routes, use Sidemail's template system. In the Sidemail dashboard, pick a premade template or create your own with the drag‑and‑drop editor. Then in your Slim route, reference the template by templateName and pass personalization data via templateProps. Sidemail merges the data and delivers a well‑formatted email.
Yes. Since Sidemail is a standard PHP class, it works anywhere in your Slim app – route handlers, middleware, or standalone scripts. You can use Slim's middleware pattern to decouple email sending from your route logic, for example sending a welcome email after a successful registration response.
Yes. Add the scheduledAt field with a future ISO 8601 timestamp to your sendEmail() call. Sidemail queues the message and delivers it at the specified time. You can view or cancel scheduled emails from the dashboard or via the API.
Wrap your $sidemail->sendEmail() call in a try/catch block and catch Sidemail\SidemailException. The exception provides the HTTP status, error code, and a clear message. You can log it with error_log() or your preferred logger and return an appropriate response.