PHPackages                             tosend/tosend-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. tosend/tosend-laravel

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

tosend/tosend-laravel
=====================

Official Laravel SDK for the ToSend email API

v1.1.1(3mo ago)0246↑50%MITPHPPHP &gt;=8.1CI passing

Since Jan 30Pushed 3mo agoCompare

[ Source](https://github.com/tosend/tosend-laravel)[ Packagist](https://packagist.org/packages/tosend/tosend-laravel)[ Docs](https://github.com/tosend/tosend-laravel)[ RSS](/packages/tosend-tosend-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

ToSend Laravel SDK
==================

[](#tosend-laravel-sdk)

Official Laravel SDK for the [ToSend](https://tosend.com) email API.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

```
composer require tosend/tosend-laravel
```

Configuration
-------------

[](#configuration)

Add your API key to your `.env` file:

```
TOSEND_API_KEY=tsend_your_api_key
```

Optionally publish the config file:

```
php artisan vendor:publish --tag=tosend-config
```

### Configuration Options

[](#configuration-options)

```
// config/tosend.php
return [
    'api_key' => env('TOSEND_API_KEY'),
    'api_url' => env('TOSEND_API_URL', 'https://api.tosend.com'),
    'from' => [
        'address' => env('TOSEND_FROM_ADDRESS'),
        'name' => env('TOSEND_FROM_NAME'),
    ],
    'timeout' => env('TOSEND_TIMEOUT', 30),
];
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use ToSend\Laravel\Facades\ToSend;

$response = ToSend::send([
    'from' => ['email' => 'hello@yourdomain.com', 'name' => 'Your App'],
    'to' => [['email' => 'user@example.com']],
    'subject' => 'Welcome!',
    'html' => 'Hello World',
]);

echo $response->messageId;
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use ToSend\Laravel\Contracts\ToSendClient;

class EmailController extends Controller
{
    public function send(ToSendClient $tosend)
    {
        $response = $tosend->send([
            'from' => ['email' => 'hello@yourdomain.com'],
            'to' => [['email' => 'user@example.com']],
            'subject' => 'Hello!',
            'html' => 'Welcome to our app!',
        ]);

        return $response->messageId;
    }
}
```

### Using the Email Builder

[](#using-the-email-builder)

```
use ToSend\Laravel\Facades\ToSend;
use ToSend\Laravel\Data\Email;
use ToSend\Laravel\Data\Attachment;

$email = Email::make(
    from: ['email' => 'hello@yourdomain.com', 'name' => 'Your App'],
    subject: 'Your Invoice'
)
    ->to(['email' => 'user@example.com', 'name' => 'John Doe'])
    ->to('another@example.com')
    ->cc('manager@example.com')
    ->bcc(['email' => 'archive@example.com'])
    ->html('Invoice Attached')
    ->text('Invoice Attached')
    ->attach(Attachment::fromPath('/path/to/invoice.pdf'));

$response = ToSend::send($email);
```

### Batch Sending

[](#batch-sending)

```
use ToSend\Laravel\Facades\ToSend;

$response = ToSend::batch([
    [
        'from' => ['email' => 'hello@yourdomain.com'],
        'to' => [['email' => 'user1@example.com']],
        'subject' => 'Hello User 1',
        'html' => 'Welcome!',
    ],
    [
        'from' => ['email' => 'hello@yourdomain.com'],
        'to' => [['email' => 'user2@example.com']],
        'subject' => 'Hello User 2',
        'html' => 'Welcome!',
    ],
]);

// Check results
echo "Sent: " . $response->successCount();
echo "Failed: " . $response->failedCount();

foreach ($response->results as $result) {
    if ($result->isSuccess()) {
        echo "Sent: " . $result->messageId;
    } else {
        echo "Failed: " . $result->message;
    }
}
```

### Account Information

[](#account-information)

```
use ToSend\Laravel\Facades\ToSend;

$info = ToSend::getAccountInfo();

echo $info->title;
echo $info->emailsUsageThisMonth;
echo $info->emailsSentLast24Hours;

foreach ($info->domains as $domain) {
    echo $domain->domainName . ': ' . $domain->verificationStatus;
}

// Get only verified domains
$verified = $info->verifiedDomains();
```

Laravel Mail Integration
------------------------

[](#laravel-mail-integration)

Use ToSend as your Laravel mail driver:

### Configure Mail Driver

[](#configure-mail-driver)

```
MAIL_MAILER=tosend
TOSEND_API_KEY=tsend_your_api_key
TOSEND_FROM_ADDRESS=hello@yourdomain.com
TOSEND_FROM_NAME="Your App"
```

```
// config/mail.php
'mailers' => [
    'tosend' => [
        'transport' => 'tosend',
    ],
],
```

### Send with Laravel Mail

[](#send-with-laravel-mail)

```
use Illuminate\Support\Facades\Mail;

// Using a Mailable
Mail::to('user@example.com')->send(new WelcomeEmail());

// Using the mail facade directly
Mail::mailer('tosend')
    ->to('user@example.com')
    ->send(new WelcomeEmail());
```

### Create a Mailable

[](#create-a-mailable)

```
namespace App\Mail;

use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Mail\Mailables\Attachment;

class WelcomeEmail extends Mailable
{
    public function envelope(): Envelope
    {
        return new Envelope(
            from: new \Illuminate\Mail\Mailables\Address('hello@yourdomain.com', 'Your App'),
            subject: 'Welcome to Our App',
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.welcome',
        );
    }

    public function attachments(): array
    {
        return [
            Attachment::fromPath('/path/to/file.pdf'),
        ];
    }
}
```

Attachments
-----------

[](#attachments)

### From File Path

[](#from-file-path)

```
use ToSend\Laravel\Data\Attachment;

$attachment = Attachment::fromPath('/path/to/document.pdf');

// With custom name and type
$attachment = Attachment::fromPath(
    path: '/path/to/document.pdf',
    name: 'custom-name.pdf',
    type: 'application/pdf'
);
```

### From Content

[](#from-content)

```
$attachment = Attachment::fromContent(
    content: $pdfContent,
    name: 'report.pdf',
    type: 'application/pdf'
);
```

### From Base64

[](#from-base64)

```
$attachment = Attachment::fromBase64(
    base64Content: $base64String,
    name: 'image.png',
    type: 'image/png'
);
```

Error Handling
--------------

[](#error-handling)

```
use ToSend\Laravel\Facades\ToSend;
use ToSend\Laravel\Exceptions\ToSendException;

try {
    $response = ToSend::send([
        'from' => ['email' => 'hello@yourdomain.com'],
        'to' => [['email' => 'user@example.com']],
        'subject' => 'Hello',
        'html' => 'Hello',
    ]);
} catch (ToSendException $e) {
    // Get error message
    echo $e->getMessage();

    // Get HTTP status code
    echo $e->getCode();

    // Get validation errors
    $errors = $e->getErrors();

    // Check error type
    if ($e->isValidationError()) {
        // Handle validation error (422)
    }

    if ($e->isAuthenticationError()) {
        // Handle auth error (401/403)
    }

    if ($e->isRateLimitError()) {
        // Handle rate limit (429)
    }
}
```

Testing
-------

[](#testing)

For testing, you can mock the ToSend client:

```
use ToSend\Laravel\Contracts\ToSendClient;
use ToSend\Laravel\Data\EmailResponse;

public function test_sends_welcome_email()
{
    $mock = $this->mock(ToSendClient::class);

    $mock->shouldReceive('send')
        ->once()
        ->andReturn(new EmailResponse(messageId: 'test-message-id'));

    // Your test code...
}
```

Or use a custom base URL for testing:

```
# .env.testing
TOSEND_API_URL=http://localhost:8080
```

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance79

Regular maintenance activity

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4caf37249178df0aa7140af2899f1b8608d8cec8180f938afb3f4cd797e1694?d=identicon)[techjewel](/maintainers/techjewel)

---

Top Contributors

[![techjewel](https://avatars.githubusercontent.com/u/1053500?v=4)](https://github.com/techjewel "techjewel (5 commits)")

---

Tags

apilaravelmailemailtransactionaltosend

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tosend-tosend-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/tosend-tosend-laravel/health.svg)](https://phpackages.com/packages/tosend-tosend-laravel)
```

###  Alternatives

[propaganistas/laravel-disposable-email

Disposable email validator

5762.6M6](/packages/propaganistas-laravel-disposable-email)[coconutcraig/laravel-postmark

Laravel package for sending mail via the Postmark API

2152.9M1](/packages/coconutcraig-laravel-postmark)[princealikhan/laravel-mautic-api

Free and Open Source Marketing Automation API

415.9k](/packages/princealikhan-laravel-mautic-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
