Documentation
Send email in PHP.
Works with: PHP 8.1 or newer. No required dependencies.
Install
Get a key under API keys in the dashboard and verify a sending domain first (how). Then add the library:
Send an email
This sends one message and passes an idempotency key, so repeating the request can never deliver it twice. Pass an idempotency key and the same key never sends twice, so a retry after a timeout is safe.
More on what you can put in a message (cc, bcc, attachments, tags, templates, scheduling) is under Sending.
Laravel
The service provider is auto-discovered. Add the key to config/services.php and a mailer to config/mail.php, then set MAIL_MAILER=mailtruss. Mailables, notifications and queued mail then go through the API: Bcc is kept, attachments and inline images work, and a retried queue job does not send twice (the Message-ID is the idempotency key).
Verify webhook signatures
Mailtruss signs every webhook with the Standard Webhooks scheme. Check the signature before you trust a request. Read the raw body from php://input.
Events, payloads and retries are on the Webhooks page.
Handle errors
Failures are Mailtruss\MailtrussException with errorName, statusCode and requestId. Every error name, with its cause and fix, is in the error catalogue.