Add Resend mailer support#2
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Resend as a supported mail transport for the Panel. Wires Resend into Laravel's mail/service configs, extends the p:environment:mail artisan command with a --resend-key option and dispatch path, surfaces a Resend-specific note on the SMTP-only admin mail settings page, and adds integration tests covering the new selection flow.
Changes:
- Register the
resendmailer inconfig/mail.php, addservices.resend.key, declareresend/resend-phpincomposer.json, and documentRESEND_KEYin.env.example. - Add a
setupResendDriverVariables()branch (plus translation key and choice entry) inEmailSettingsCommand, and add a from-address presence check. - Add new integration tests for the command and a Resend hint to the admin mail settings disabled-state view.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
config/mail.php |
Registers the resend mailer entry and updates the supported-list comment. |
composer.json |
Adds resend/resend-php ^0.10.0 runtime dependency. |
.env.example |
Documents the new RESEND_KEY variable. |
app/Console/Commands/Environment/EmailSettingsCommand.php |
Adds Resend choice, --resend-key option, Resend setup method, and a from-address validation. |
resources/lang/en/command/messages.php |
Adds ask_resend_key prompt translation. |
resources/views/admin/settings/mail.blade.php |
Shows a Resend-specific note when mail.default === 'resend'. |
tests/Integration/Commands/Environment/EmailSettingsCommandTest.php |
New integration tests for SMTP/Resend selection and from-address validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| */ | ||
| private function setupResendDriverVariables() | ||
| { | ||
| $this->variables['MAIL_DRIVER'] = 'resend'; |
Comment on lines
+14
to
+66
| $this->artisan('p:environment:mail', [ | ||
| '--driver' => 'smtp', | ||
| '--host' => 'smtp.test.com', | ||
| '--port' => '587', | ||
| '--username' => 'user@test.com', | ||
| '--password' => 'secret', | ||
| '--encryption' => 'tls', | ||
| '--email' => 'panel@test.com', | ||
| '--from' => 'Test Panel', | ||
| ])->assertExitCode(0); | ||
|
|
||
| // Verify the .env file was updated | ||
| $env = file_get_contents(base_path('.env')); | ||
| $this->assertStringContainsString('MAIL_DRIVER=smtp', $env); | ||
| $this->assertStringContainsString('MAIL_HOST=smtp.test.com', $env); | ||
| $this->assertStringContainsString('MAIL_PORT=587', $env); | ||
| $this->assertStringContainsString('MAIL_FROM_ADDRESS=panel@test.com', $env); | ||
| } | ||
|
|
||
| /** | ||
| * Test that the Resend driver can be selected and configured. | ||
| */ | ||
| public function test_resend_driver_selection(): void | ||
| { | ||
| $this->artisan('p:environment:mail', [ | ||
| '--driver' => 'resend', | ||
| '--resend-key' => 're_test_123456789', | ||
| '--email' => 'panel@test.com', | ||
| '--from' => 'Test Panel', | ||
| ])->assertExitCode(0); | ||
|
|
||
| $env = file_get_contents(base_path('.env')); | ||
| $this->assertStringContainsString('MAIL_DRIVER=resend', $env); | ||
| $this->assertStringContainsString('RESEND_KEY=re_test_123456789', $env); | ||
| $this->assertStringContainsString('MAIL_FROM_ADDRESS=panel@test.com', $env); | ||
| } | ||
|
|
||
| /** | ||
| * Test that the Resend driver shows an error when no key is provided. | ||
| */ | ||
| public function test_resend_driver_warns_without_key(): void | ||
| { | ||
| $this->artisan('p:environment:mail', [ | ||
| '--driver' => 'resend', | ||
| '--resend-key' => '', | ||
| '--email' => 'panel@test.com', | ||
| '--from' => 'Test Panel', | ||
| ])->assertExitCode(0); | ||
|
|
||
| // The command should still write the env (it warns but doesn't abort) | ||
| $env = file_get_contents(base_path('.env')); | ||
| $this->assertStringContainsString('MAIL_DRIVER=resend', $env); | ||
| } |
Comment on lines
+168
to
+176
| $this->variables['RESEND_KEY'] = $this->option('resend-key') ?? $this->ask( | ||
| trans('command/messages.environment.mail.ask_resend_key'), | ||
| $this->config->get('services.resend.key') | ||
| ); | ||
|
|
||
| if (empty($this->variables['RESEND_KEY'])) { | ||
| $this->output->error('A Resend API key is required when using the Resend mail driver.'); | ||
| $this->output->comment('You can obtain an API key at https://resend.com/api-keys'); | ||
| } |
| "predis/predis": "^3.3.0", | ||
| "prologue/alerts": "^1.3.0", | ||
| "psr/cache": "^3.0.0", | ||
| "resend/resend-php": "^0.10.0", |
Comment on lines
+67
to
+71
| if (empty($this->variables['MAIL_FROM_ADDRESS'])) { | ||
| $this->output->error('A from address is required for sending emails.'); | ||
|
|
||
| return 1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.