Installation Docker Self-Hosted Technical November 16, 2026

How to Install Laravel Mail on Your Own Server (Step-by-Step Guide)

Stefan Bogdan

Stefan Bogdan

Lead Developer

How to Install Laravel Mail on Your Own Server (Step-by-Step Guide)

The power of a self-hosted email marketing solution lies in control, but that control often comes with the reputation of being difficult to set up. Laravel Mail changes that. By leveraging Docker, we've made the installation process as seamless as possible, shielding you from the complexities of server configuration while giving you all the benefits of a dedicated environment. In this guide, we'll walk you through everything you need to get Laravel Mail up and running on your own infrastructure, from choosing a provider to sending your first campaign. In less than 30 minutes, you can have a world-class marketing platform entirely under your own domain.

Why Self-Hosting is the Strategic Choice for 2026

Before we dive into the 'how,' let's briefly touch on the 'why.' In 2026, privacy and cost-efficiency are no longer optional—they are competitive necessities. By self-hosting your email platform, you ensure that your most valuable asset (your customer data) never leaves your control. You're not just saving on 'subscriber taxes'; you're building a resilient infrastructure that can scale with your business without the overhead of SaaS limitations. Self-hosting is the ultimate hedge against platform risk and rising subscription costs. It's the difference between 'renting' your audience and 'owning' your relationship with them.

Phase 1: Selecting Your Server Infrastructure

Your choice of server will impact your delivery speed and the overall snappiness of the Laravel Mail interface. While you can run Laravel Mail on almost any provider, we recommend choosing a VPS with good network performance and SSD storage. In 2026, the options for high-quality, low-cost hosting are better than ever.

Recommended Providers and Plans

  • DigitalOcean: The 'Basic' Droplet with 4GB RAM ($24/mo) is a sweet spot for medium-sized lists. Their user-friendly interface and robust API make them a top choice for developers.
  • Hetzner: The CPX21 or CPX31 plans offer incredible value for European and US-based senders. For under €10, you can get performance that rivals much more expensive plans from other providers.
  • AWS: A t3.medium or t3.large instance provides great burst capacity for high-volume sending. Ideal if you're already within the AWS ecosystem and want to take advantage of VPCs and IAM roles.

System Requirements:

Minimum (Testing/Small Lists):
  • RAM: 2 GB
  • CPU: 2 vCPU
  • Disk: 20 GB SSD
Recommended (Production/AI Features):
  • RAM: 4 GB+
  • CPU: 4 vCPU+
  • Disk: 50 GB+ NVMe SSD

Operating System: We strongly recommend Ubuntu 24.04 LTS or 22.04 LTS. These are the most tested environments and have the best support for modern Docker versions and security updates. Avoid 'minimal' distributions unless you are very comfortable with Linux administration.

Phase 2: Preparing the Environment

Once you've spun up your server and SSH'd in, the first step is to ensure your system is secure and up to date. This foundation is critical for the stability of your marketing platform.

Step 1: System Update and Basic Security

sudo apt update && sudo apt upgrade -y
sudo apt install curl git ufw -y

It's also a good idea to set up a basic firewall. We'll open the necessary ports later, but for now, let's allow SSH so you don't get locked out. Security should never be an afterthought:

sudo ufw allow ssh
sudo ufw enable

Step 2: Installing Docker and Docker Compose

Laravel Mail is distributed as a Docker-ready application. This means you don't need to manually install PHP, MySQL, or Redis on your server—Docker handles it all in isolated containers. This 'containerized' approach ensures that the application runs exactly the same way on your server as it does on ours.

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Install Docker Compose
sudo apt install docker-compose-v2 -y

Phase 3: Deploying Laravel Mail

Now we're ready for the main event. We'll clone the repository and configure the application settings.

Step 3: Clone the Repository

git clone https://github.com/laravel-mail/laravel-mail.git
cd laravel-mail

Step 4: Configure Environment Variables

The .env file is where you define your database passwords, application URL, and other sensitive settings. Use the provided template to get started. Be careful here—these settings control the 'brain' of your application.

cp .env.example .env
nano .env

Key settings to update in `.env`:

  • APP_URL: Set this to your domain (e.g., https://mail.yourcompany.com). This is used for generating tracking links and assets.
  • DB_PASSWORD: Choose a strong, unique password for your database.
  • APP_KEY: This will be generated in the next step.
  • TIMEZONE: Set this to your local timezone to ensure scheduled campaigns go out at the right time.

Step 5: Launch the Stack

This command will pull the optimized images and start the web server, the database, the Redis cache, and the background workers. The first time you run this, it may take a few minutes as it downloads the images.

docker compose up -d

Phase 4: Post-Installation and Optimization

After the containers are up, there are a few final steps to ensure everything is secure and performing well. We're almost at the finish line.

Step 6: Finalize Configuration

Run the following command to generate your application key and run the initial database migrations. This sets up the database schema and prepares the application for use:

docker compose exec app php artisan key:generate
docker compose exec app php artisan migrate --seed

Step 7: Configuring Firewall for Mail and Web

Laravel Mail needs a few ports to be accessible. Port 5210 is the default for the web UI, but if you're using a reverse proxy, you'll only need to open 80 and 443.

# Web UI (if accessing directly)
sudo ufw allow 5210/tcp

# SMTP (if using local KumoMTA relay)
sudo ufw allow 2525/tcp

Using a Reverse Proxy for SSL (Highly Recommended)

For a production environment, you should always serve Laravel Mail over HTTPS. This is not just for security; it's also for deliverability. Modern email clients can be sensitive to tracking links served over insecure connections. The easiest way to handle SSL is to use Nginx Proxy Manager or Traefik. These tools can automatically manage Let's Encrypt certificates for you, ensuring your connection is always encrypted and your domain reputation is protected.

Phase 5: Connecting Your Sending Infrastructure

With the software running, you now need a 'tailpipe' for your emails. Laravel Mail supports all major providers. For high-volume sending at the lowest cost, we recommend connecting AWS SES. For developers who want the best possible API experience, Resend is a fantastic choice. If you want 100% control, you can use the built-in KumoMTA for your own SMTP relay.

Common Troubleshooting Tips

  • 'Permission Denied' on Docker: If you get a permission error, ensure your user is in the 'docker' group: sudo usermod -aG docker $USER and log out/in.
  • Database Connection Refused: On the first run, the database might take longer to initialize. If migrations fail, wait 30 seconds and try again.
  • Out of Memory Errors: If you're on a smaller server (2GB), ensure you have a swap file configured. This provides a 'safety net' for memory-intensive tasks like AI content generation.
  • Port Conflicts: If port 5210 is already in use, you can change the mapping in the docker-compose.yml file.

Scaling for the Future

One of the beauties of a Docker-based setup is scalability. As your list grows from 10,000 to 1,000,000 subscribers, you don't need to 'migrate' to a new platform. You can simply upgrade your VPS and adjust your Docker resource limits. Laravel Mail is designed to scale horizontally, meaning you can add more 'worker' containers to handle higher sending volumes without any downtime.

Conclusion: You Are Now in Control

Congratulations! You've successfully deployed a world-class email marketing platform on your own infrastructure. You've escaped the 'subscriber tax' and taken a major step toward total data sovereignty. You can now build, segment, and send with the freedom that only self-hosting provides. As you grow, remember that Laravel Mail is designed to scale with you. Whether you're sending to 100 people or 1,000,000, your software is now a fixed, manageable cost. Ready to send your first campaign? Check out our deliverability guide to ensure you're starting with the best possible reputation.

Join the Self-Hosted Revolution

Need help with more advanced configurations or looking for best practices? Check out our full documentation and community forums.

View Full Documentation

Note: Blog content is currently available in English.

Tags: #Installation#Docker#Self-Hosted#Technical

Enhance your marketing setup with your own email marketing platform.

Join the growing number of SaaS platforms using Laravel Mail to offer email marketing solutions to their customers.