Blog

Laravel and Django: switch your mail driver to Vaartix in one afternoon

· 3 min read · Vaartix team

If your app is built on Laravel or Django, you probably already send email the framework way: Mailables and notifications in Laravel, send_mail and the built-in password-reset emails in Django. Switching to Vaartix doesn't mean rewriting any of that. You change the mail driver, and everything your app already sends goes through Vaartix.

Before you start

  • Sign up free and create an API key under API keys. Give your app a send-only key: if it ever leaks, it can't read your email history or create more keys.
  • Until you verify your domain, a new account can send only to test addresses. That's enough to try everything below: send from @test.vaartix.com to [email protected].

Laravel: the vaartix mail driver

The PHP SDK registers a vaartix mail driver automatically on Laravel 12 and 13, so the Mail facade, Mailables, notifications and queued mail all go through Vaartix.

composer require vaartix/vaartix-php

Then point Laravel at it:

# .env
MAIL_MAILER=vaartix
[email protected]
VAARTIX_API_KEY=vx_live_...
// config/services.php
'vaartix' => [
    'key' => env('VAARTIX_API_KEY'),
],

// config/mail.php, inside 'mailers'
'vaartix' => [
    'transport' => 'vaartix',
],

That's it. Mail::to($user)->send(new OrderConfirmed($order)) now sends through Vaartix. Laravel's ->tag() and ->metadata() become Vaartix tags, so you can filter by them in the dashboard. The full guide is Send email from Laravel.

Django: the vaartix email backend

The Python SDK includes a Django email backend (Django 4.2 and later), so send_mail, EmailMessage and Django's own emails, such as password resets, all go through Vaartix.

pip install "vaartix[django]"
# settings.py
import os

VAARTIX_API_KEY = os.environ["VAARTIX_API_KEY"]
DEFAULT_FROM_EMAIL = "Acme <[email protected]>"

# Django 6.1 and newer
MAILERS = {"default": {"BACKEND": "vaartix.django.EmailBackend"}}

# Django 4.2 to 6.0
EMAIL_BACKEND = "vaartix.django.EmailBackend"

Use the setting that matches your Django version. HTML alternatives, attachments, inline images, cc, bcc, reply-to and custom headers all work, and after sending, message.vaartix_id holds the Vaartix email ID. The full guide is Send email from Django.

Hear about bounces in your app

Once mail is flowing, add a webhook so your app knows when an address bounces or someone reports spam. Both SDKs verify the signature for you. Two things to remember in both frameworks:

  • Exempt the webhook route from CSRF protection. Requests come from Vaartix, not from a browser form; the signature check is what keeps it safe.
  • Verify the raw request body: $request->getContent() in Laravel, request.body in Django.

Both guides include a ready-to-use webhook route. Our post on bounces and complaints explains what to do with each event.

An afternoon, not a migration project

  1. Install the SDK and switch the driver or backend (15 minutes).
  2. Send a few test emails to [email protected] and check them in the dashboard's logs.
  3. Verify your domain: publish the DNS records Vaartix gives you. Our DNS walkthrough covers GoDaddy, Hostinger and Cloudflare.
  4. Add the webhook route, deploy, and watch your first real emails arrive.

Prefer SMTP? Any app that speaks SMTP can use smtp.vaartix.com on ports 465 or 587, with the username vaartix and an API key as the password. See the SMTP guide.

Vaartix is a transactional email API built in India. It sends through Amazon SES in Mumbai, keeps your data in India and is priced in rupees. Anyone can sign up free, and the Free plan has every feature.

Sign up free