- How do I integrate resend/resend-php with Laravel’s Mail facade for transactional emails?
- Replace `Mail::send()` with `$resend->emails->send()` in your Laravel app. For password resets, use the Resend API directly in your `ResetPasswordController` or wrap it in a service class. The SDK’s fluent interface mirrors Laravel’s Mailable patterns, so migration is straightforward. Start with critical flows like auth emails before expanding to other use cases.
- Does resend/resend-php support Laravel queues for async email sending?
- Yes, wrap Resend calls in a `SendEmailJob` and dispatch it via Laravel’s queue system. This handles retries and rate limits automatically. Use Resend’s idempotency keys to prevent duplicate sends if jobs fail. For production, configure `queue:failed` table to retry failed jobs with a fallback SMTP if Resend is unavailable.
- What Laravel versions and PHP requirements does resend/resend-php support?
- The package requires **PHP 8.1+** and is tested with **Laravel 9+**. It avoids global overrides, so it won’t conflict with Laravel’s core. For older Laravel versions (8.x), check the GitHub issues for compatibility patches, but the SDK is designed for modern PHP features like named arguments and enums.
- How do I handle email templates in Laravel if I’m migrating from Blade to Resend?
- Replace Blade templates with Resend’s **templates API**. Use dynamic template variables (e.g., `{{user.name}}`) to mirror your existing Blade logic. For complex layouts, pre-render Blade templates in a service layer and pass the HTML to Resend’s `html` payload. The Laravel example repo shows how to sync templates between Blade and Resend.
- Can I use resend/resend-php for newsletters or is it only for transactional emails?
- While optimized for transactional emails, the SDK supports Resend’s **broadcasts API** for newsletters. Use `$resend->emails->sendMany()` for bulk sends, but note Resend’s free tier limits (1,000 emails/month). For high-volume newsletters, consider Resend’s paid plans or integrate with Laravel’s queue system to batch sends and avoid throttling.
- How do I test resend/resend-php in Laravel without hitting Resend’s API?
- Use Laravel’s `MailFake` for unit tests to mock email sends. For integration tests, mock the Resend client with PHPUnit’s `createMock()` or use a testing API key from Resend’s sandbox environment. The SDK’s clean interface makes it easy to swap implementations for testing. Example test cases are in the [Laravel example repo](https://github.com/resend/resend-laravel-example).
- What happens if Resend’s API goes down? Can I fallback to another SMTP service?
- Implement a fallback by catching exceptions (e.g., `ResendException`) and retrying with a secondary SMTP like Amazon SES or Mailgun. Wrap Resend calls in a service class with a `try-catch` block and queue the fallback job. Monitor Resend’s [status page](https://resend.com/status) and set up Laravel’s `queue:failed` table to log issues for manual review.
- Does resend/resend-php support webhooks for tracking email opens/clicks?
- Yes, use Resend’s **webhooks API** to listen for events like `email.opened` or `email.click`. In Laravel, route webhooks to a controller and dispatch events (e.g., `EmailOpened`) or update user models via observers. The SDK provides a `webhooks` resource to manage subscriptions. For async processing, use Laravel’s queue system to avoid blocking requests.
- How do I migrate existing Laravel contacts to Resend’s contacts API?
- Sync users to Resend’s contacts API using Laravel’s `UserObserver` or a queue job. For GDPR compliance, include an `unsubscribed` field and provide an opt-out link in emails. Use Resend’s `contacts->upsert()` method to batch updates. The migration should be idempotent—re-running it shouldn’t duplicate contacts. Test with a small subset before full deployment.
- Are there alternatives to resend/resend-php for Laravel, and when should I choose them?
- Alternatives include **Laravel’s built-in Mail facade** (for SMTP) or third-party SDKs like **Mailgun’s PHP SDK** or **SendGrid’s laravel-sendgrid-driver**. Choose Resend if you want a modern, API-driven solution with no SMTP setup. Use SMTP alternatives if you need self-hosted control, lower costs at scale (>100K emails/month), or advanced deliverability tuning. Resend excels for startups and transactional emails with minimal boilerplate.