Installation | laravel-mailcoach-sdk-rust | Spatie       

 SPATIE  

laravel-mailcoach-sdk-rust
==========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-mailcoach-sdk-rust](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1)  Installation

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1) 

  Installation    
- [ Introduction ](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1/support-us)
- [ Installation ](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1/usage)
- [ Testing ](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/laravel-mailcoach-sdk-rust/v1/changelog)

 Installation
============

###  On this page 

1. [ Register the service ](#content-register-the-service)

Requires Rust 1.99 or newer. This package is not published to crates.io. Use a local path dependency:

```
[dependencies]
spatie-laravel-mailcoach-sdk = { path = "../laravel-mailcoach-sdk-rust" }
```

HTTP operations need a Tokio runtime. The default `laravel` feature includes native framework registration and the package-tools crate pinned to a reviewed revision. Disable default features to use the client without framework integration. Both modes use the `spatie_mailcoach_sdk` import name. Public Git dependencies need no token. CI uses `SPATIE_GITHUB_TOKEN` for authenticated dependency reads only when configured.

Register the service
--------------------------------------------------------------------------------------------------------------------

```
use spatie_mailcoach_sdk::service_provider;

let app = laravel::Application::configure()
    .with_providers(|providers| {
        providers.add(service_provider());
    })
    .create();
```

Set the SDK environment variables:

- `MAILCOACH_API_TOKEN`: API bearer token.
- `MAILCOACH_API_ENDPOINT`: installation root or API base ending in `/api`.

The mailer's `MAILCOACH_TOKEN` and `MAILCOACH_DOMAIN` are never read by the SDK. Application config callbacks can replace the provider defaults:

```
use spatie_mailcoach_sdk::{MailcoachConfig, service_provider};

let app = laravel::Application::configure()
    .with_providers(|providers| { providers.add(service_provider()); })
    .with_config(|config, _| {
        config.set(MailcoachConfig {
            api_token: "example-token".into(),
            endpoint: "https://example.mailcoach.app".into(),
        });
    })
    .create();
```

The provider creates one shared client on first resolution. Controllers and jobs can receive `laravel::container::Inject<Mailcoach>`. Resolving invalid configuration returns a framework error; it does not create a dummy client or send an HTTP request.

Applications can replace the client using `.with_services(|services| { services.instance(custom_client); })`. Application bindings take precedence over the provider. The SDK defines no database models or queue jobs, and does not select a queue or database connection.

Keep API tokens in application secrets, not source control. Use HTTPS for hosted and self-hosted installations outside local development.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
