Laravel
Laravel’s SMTP mailer works with SpacePost without any packages.
MAIL_MAILER=smtpMAIL_SCHEME=smtpMAIL_HOST=smtp.spacepost.devMAIL_PORT=25976MAIL_USERNAME=spacepostMAIL_PASSWORD=sp_live_YOUR_API_KEYMAIL_ENCRYPTION=tlsMAIL_FROM_ADDRESS="hello@acme.com"MAIL_FROM_NAME="Acme"Laravel 11 and later read MAIL_SCHEME=smtp and upgrade the connection with STARTTLS; Laravel 10 and earlier read MAIL_ENCRYPTION=tls. Keeping both lines works on every version. Do not use smtps or ssl: implicit TLS (port 465) is not offered yet.
Send as usual:
use Illuminate\Support\Facades\Mail;use App\Mail\OrderShipped;
Mail::to($user)->send(new OrderShipped($order));Tags and scheduling
Section titled “Tags and scheduling”Add SpacePost’s control headers in your Mailable:
use Illuminate\Mail\Mailables\Headers;
public function headers(): Headers{ return new Headers(text: [ 'X-SpacePost-Tags' => 'category=order, order_id=' . $this->order->id, ]);}Queues
Section titled “Queues”Mailables sent with Mail::queue() work as normal; the queue worker talks to SpacePost over SMTP. Keep the number of concurrent workers within the rate limit.