Installation | laravel-mailcoach-mailer-rust | Spatie       

 SPATIE  

laravel-mailcoach-mailer-rust
=============================

spatie.be/open-source

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

 Version   v1      

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

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

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

Requires Rust 1.99 or newer and `laravel-rust =0.1.0`. Use a local path dependency:

```
[dependencies]
spatie-laravel-mailcoach-mailer = { path = "../laravel-mailcoach-mailer-rust" }
laravel = { package = "laravel-rust", version = "=0.1.0", default-features = false }
```

Register the native service provider, then configure a named mailer. Registration does not choose a default mailer; set `config.mail.default` separately when needed.

```
use laravel::Application;
use spatie_mailcoach_mailer::{Mailcoach, service_provider};

let app = Application::configure()
    .with_providers(|providers| { providers.add(service_provider()); })
    .with_config(|config, _| {
        let settings = config.section::<Mailcoach>().clone();
        config.mail.add_mailer("mailcoach", settings);
    })
    .create();
```

The provider uses `spatie-laravel-package-tools`, pinned to a reviewed Git revision. Both repositories are public; no token is required to fetch them. CI optionally uses `SPATIE_GITHUB_TOKEN` when set. Nothing is published to crates.io.

Environment defaults are read through the framework's `Env`:

- `MAILCOACH_DOMAIN`: installation hostname.
- `MAILCOACH_TOKEN`: transactional mail bearer token.
- `MAILCOACH_API_BASE_URL`: optional HTTP(S) override.
- `MAILCOACH_TIMEOUT`: request timeout in seconds, default 10.

`MAILCOACH_API_TOKEN` and `MAILCOACH_API_ENDPOINT` belong to the Mailcoach SDK and are never read by this mailer. A missing `MAILCOACH_TOKEN` fails delivery configuration even when an SDK token is present. Keep the mailer's credentials separate from SDK credentials when using both packages in one application.

The provider stores these in the typed `Mailcoach` config section. Application config can replace it with `config.set(Mailcoach::new(domain, token))` before adding a named mailer. Alternatively, pass settings directly to `config.mail.add_mailer` for independent credentials and endpoints. `Mailcoach::from_env(env)` is available when configuring a mailer without the provider. Low-level `register(app.mail())` still registers just the driver, not config defaults or the command.

`domain` is a hostname without a scheme or path. It uses HTTPS. To route through a trusted internal proxy or a local fake, call `.api_base_url("http://mailcoach-service:8080/prefix/")`. The request appends `/api/transactional-mails/send`, preserving the prefix. An empty override falls back to the domain. The override must be an absolute HTTP(S) URL without user credentials, query or fragment.

- Tokens must be nonempty and contain only valid HTTP header characters.
- Configuration errors occur on the named mailer's first send, or immediately when constructing `MailcoachTransport::new(settings)` explicitly. Match `ConfigError` variants instead of parsing error text.
- Debug output redacts tokens. API response bodies may contain personal data; treat delivery errors accordingly.

The request timeout defaults to ten seconds and can be changed with `.timeout(Duration::from_secs(30))`. Zero is rejected. No SDK, database, worker or external service is needed for the local transport tests.

 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)
