Mailjet Email Service Setup

Complete guide for setting up Mailjet email service with sender addresses, API keys, webhooks, and email tracking for SendPortal.

Sending Emails

To send e-mails using the Mailjet provider, you will need a Mailjet account. If you don't already have an account, visit the Mailjet website to create one.

💰 Free Plan Available

The Mailjet Free plan offers you 200 emails a day, which is enough to cover your basic needs if you are a small sender.

Sender Address Configuration

When you first begin, you need to add and configure the "From:" email address, also known as the Sender Address.

Extensive documentation for this step is available in the Mailjet support documentation.

API Keys Integration

To integrate SendPortal with Mailjet, you need to copy the API Key and the API Secret Key, which are generated automatically when your account is created.

Simply paste these keys into your SendPortal provider configuration to complete the integration.

🔐 Security Option: Sub-account API Keys

Alternatively, if you don't want to use the Master API Key (which grants full access to your account), you can set up Sub-account API Keys and limit their scope for enhanced security.

Email Tracking Setup

✅ Default Tracking Enabled

By default the tracking options for opens and clicks are activated for all new accounts. These settings can be changed on your Account Preferences page.

Keep in mind that SendPortal will always override them with the values that you choose in the application when creating a new campaign.

🔗 Webhooks Configuration

To enable tracking however you will have to set up Webhooks from the Account Information page.

Webhook URL Configuration

The URL depends on your domain, but must end with /api/v1/webhooks/mailjet.

https://campaigns.marketing.com/api/v1/webhooks/mailjet

For example, if SendPortal is installed at https://campaigns.marketing.com, then each webhook should point to the URL shown above.

Event Configuration

You'll need to add an entry for each type of event you want to track, but the URL is the same for each one of them.

If you want to limit the number of calls, you can choose to group together events that occurred over the last second. SendPortal is able to handle both single and grouped events.

🎉 Setup Complete!

That's it! You're now setup to send and track e-mails using Mailjet. Your webhooks will automatically capture email events and send them to your SendPortal installation for comprehensive tracking and analytics.

Quick Setup Summary

Account & Sending Setup

1
Create Mailjet account (free plan available)
2
Configure sender address ("From:" email)
3
Copy API Key and API Secret Key
4
Configure SendPortal provider

Tracking Setup

1
Verify default tracking is enabled
2
Navigate to Account Information page
3
Set up webhooks with endpoint URL
4
Configure event types (optional grouping)

Important Notes & Best Practices

API Key Security

🔒 Master API Key

The Master API Key grants full access to your Mailjet account. Use with caution and never commit to version control.

✅ Sub-account Keys

For enhanced security, create Sub-account API Keys with limited scope instead of using the Master API Key.

Tracking & Analytics

📊 Default Tracking

Opens and clicks tracking are enabled by default for all new Mailjet accounts

⚙️ Campaign Override

SendPortal will override account settings with campaign-specific tracking preferences

🔄 Event Grouping

Group events by second to reduce webhook calls while maintaining functionality

Webhook Configuration Details

Required Webhook URL Format

https://yourdomain.com/api/v1/webhooks/mailjet

Replace yourdomain.com with your actual SendPortal installation domain.

Performance Optimization

SendPortal can handle both individual events and grouped events (events that occurred within the same second). Event grouping helps reduce the number of webhook calls to your server.

delivery
tls_advertise_hosts = *
tls_certificate = /etc/ssl/exim.crt
tls_privatekey = /etc/ssl/exim.pem

Routing Configuration

DNS Lookup Router

Routes emails based on DNS MX records

dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp

Manual Route Router

Routes emails to a specific host

my_smarthost:
driver = manualroute
transport = smarthost_smtp
route_list = smarthost.example.com

Transport Configuration

Local Delivery

Delivers emails to local mailboxes

local_delivery:
driver = appendfile
file = /var/mail/$local_part

Remote SMTP

Sends emails to remote servers

remote_smtp:
driver = smtp

Laravel Integration

Laravel .env Configuration

Configure Laravel to work with your local Exim installation by setting these environment variables:

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="your-email@example.com"

Note: Make sure your Exim configuration allows the web server user (typically www-data) to send emails without authentication when connecting from localhost.

Security & Monitoring

Security Considerations

Privilege Management

Run Exim with minimal privileges

TLS Encryption

Always enable TLS for secure delivery

Input Sanitization

Sanitize inputs when using pipe transports

Monitoring & Debugging

Queue Management

exim -bp

List the mail queue

Address Testing

exim -bt user@domain.com

Test address routing

Debug Mode

exim -d

Enable debugging output

Ready to Send Emails with Mailjet?

Follow this guide to set up your sender address, configure API keys, and enable webhook tracking for your email campaigns.

Create Account → Configure Sender → Setup Webhooks

Exim Configuration for Laravel

Complete reference documentation for configuring Exim Mail Transfer Agent for Laravel applications, covering installation, security, routing, and integration.

Introduction to Exim and Laravel

Exim is a highly flexible and powerful Mail Transfer Agent (MTA) used to route, deliver, and receive email messages. As an MTA, Exim operates at the core of email delivery systems, handling the complexities of SMTP (Simple Mail Transfer Protocol) and ensuring emails reach their intended destinations.

For Laravel developers, Exim is particularly relevant because Laravel's mail functionality relies on an underlying MTA to send emails. While Laravel provides an elegant abstraction layer for sending emails via its Mail facade and configuration files, the actual delivery of emails depends on the MTA configured on the server.

Why Configure Exim for Laravel?

  • Troubleshooting: When emails fail to send, knowing how Exim works helps diagnose and resolve issues
  • Security: Properly configuring Exim ensures your email server is secure and not exploited for spam
  • Advanced Use Cases: Custom email routing, rate limiting, or third-party service integration

Core Exim Concepts

Runtime Configuration

Exim's behavior is controlled by a single configuration file, typically located at /etc/exim/exim.conf. This file is divided into sections, each defining specific aspects of Exim's operation.

# Configuration file uses key-value format
# Comments are denoted by the # symbol
qualify_domain = yourdomain.com

Exim Drivers

Routers

Determine how to route an email (local mailbox or remote server)

Transports

Define how an email is delivered (via SMTP or to local file)

Authenticators

Handle SMTP authentication for incoming/outgoing emails

Basic Mail Flow

1. Reception

Email accepted via SMTP

2. Routing

Routers determine destination

3. Delivery

Transports handle delivery

Installing Exim

Building from Source

To build Exim from source, you'll need dependencies like PCRE2 library for regular expressions and DBM libraries for database lookups.

# Download and extract Exim source
wget https://ftp.exim.org/pub/exim/exim4/exim-4.96.tar.gz
tar -xvzf exim-4.96.tar.gz
cd exim-4.96
# Configure and build
./configure --with-pcre2 --with-dbm
make
sudo make install

Key Configuration for Laravel

Essential Settings

Qualify Domain

Sets default domain for unqualified addresses

qualify_domain = yourdomain.com

Local Domains

Specifies which domains are local

local_domains = yourdomain.com : yourseconddomain.net

Trusted Users

Users allowed to send without authentication

trusted_users = www-data : myuser

TLS/SSL Options

Enable secure email delivery

tls_advertise_hosts = *
tls_certificate = /etc/ssl/exim.crt
tls_privatekey = /etc/ssl/exim.pem

Routing Configuration

DNS Lookup Router

Routes emails based on DNS MX records

dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp

Manual Route Router

Routes emails to a specific host

my_smarthost:
driver = manualroute
transport = smarthost_smtp
route_list = smarthost.example.com

Transport Configuration

Local Delivery

Delivers emails to local mailboxes

local_delivery:
driver = appendfile
file = /var/mail/$local_part

Remote SMTP

Sends emails to remote servers

remote_smtp:
driver = smtp

Laravel Integration

Laravel .env Configuration

Configure Laravel to work with your local Exim installation by setting these environment variables:

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="your-email@example.com"

Note: Make sure your Exim configuration allows the web server user (typically www-data) to send emails without authentication when connecting from localhost.

Security & Monitoring

Security Considerations

Privilege Management

Run Exim with minimal privileges

TLS Encryption

Always enable TLS for secure delivery

Input Sanitization

Sanitize inputs when using pipe transports

Monitoring & Debugging

Queue Management

exim -bp

List the mail queue

Address Testing

exim -bt user@domain.com

Test address routing

Debug Mode

exim -d

Enable debugging output

Ready to Configure Exim for Laravel?

Start with the basic configuration, set up your routers and transports, then integrate with your Laravel application for reliable email delivery.

vi /etc/exim/exim.conf