Laravel Plugin

Use your favorite mail provider Zupost, seamless with our Laravel Plugin.

Mail Integration

Native Laravel Mail driver support

Blade Ready

Works with Laravel's template engine

Zupost is a mail provider that allows you to send emails easily and efficiently. This package provides Zupost integration for Laravel and Symfony Mailer, allowing you to send transactional emails through Zupost using Laravel's built-in mail system or the Zupost Facade directly.

Installation

Install Zupost for Laravel via Composer:
composer require zupost/laravel

Setting Up

Next, configure your Zupost API key in your application's .env file:
ZUPOST_API_KEY=your_api_key_here
Optionally, publish the configuration file:
php artisan vendor:publish --tag=zupost-config

Usage Examples

Using Laravel's Mail System

Zupost for Laravel comes bundled with a Laravel mailer transport. To start using it, add a new mailer definition in your config/mail.php:
'zupost' => [
    'transport' => 'zupost',
],
Then update the MAIL_MAILER environment variable:
MAIL_MAILER=zupost
Now you can send emails using Laravel's standard Mail API:
use Illuminate\Support\Facades\Mail;

Mail::raw('Hello from Zupost!', function ($message) {
    $message->from('sender@yourdomain.com')
        ->to('recipient@example.com')
        ->subject('Hello World');
});
Or with a Mailable:
Mail::to('recipient@example.com')->send(new WelcomeEmail());

Using the Zupost Facade

You can also use the Zupost facade to access the API directly:
use Zupost\Laravel\Facades\Zupost;

// Send with HTML content
$response = Zupost::getFacadeRoot()->emails->send([
    'from' => 'sender@yourdomain.com',
    'to' => 'recipient@example.com',
    'subject' => 'Hello World',
    'html' => '<h1>Hello!</h1>',
]);

echo $response->id;

Send with markdown

use Zupost\Laravel\Facades\Zupost;

Zupost::getFacadeRoot()->emails->send([
    'from' => 'sender@yourdomain.com',
    'to' => 'recipient@example.com',
    'subject' => 'Newsletter',
    'markdown' => '# Hello\n\nThis is **markdown** content.',
]);

Send with a Template

use Zupost\Laravel\Facades\Zupost;

Zupost::getFacadeRoot()->emails->send([
    'from' => 'sender@yourdomain.com',
    'to' => ['user1@example.com', 'user2@example.com'],
    'subject' => 'Welcome!',
    'templateId' => 'welcome-template',
    'variables' => ['name' => 'John'],
]);

Send with Attachments

You can attach files to your emails by providing them as base64-encoded strings via the Facade.

use Zupost\Laravel\Facades\Zupost;

Zupost::getFacadeRoot()->emails->send([
    'from' => 'sender@yourdomain.com',
    'to' => 'recipient@example.com',
    'subject' => 'Invoice',
    'html' => '<p>Please find the invoice attached.</p>',
    'attachments' => [
        [
            'filename' => 'invoice.pdf',
            'content' => base64_encode(file_get_contents('/path/to/invoice.pdf')),
        ],
    ],
]);

Contribute on GitHub

Found an issue or want to contribute? Check out the repository for this project. We welcome contributions of all kinds!

Laravel Plugin