resend-php icon indicating copy to clipboard operation
resend-php copied to clipboard

feat(Email): Add a fluent interface

Open GatienFrenchDev opened this issue 1 year ago • 0 comments

Closes #2

Hello,

I’ve worked on adding a fluent interface to simplify the process of sending emails, as suggested in issue #2. With this approach, users can now compose emails in a more intuitive and chained way, which should improve the development experience:

use Resend\Email;

$resend = Resend::client('re_123456789');

$email = (new Email())
    ->to('...')
    ->sendFrom('...')
    ->subject('...')
    ->text('...');

if ($user->is_premium) {
    $email->html('...');
}

$resend->send($email);

I’ve implemented the methods necessary to create this fluent interface. Although I wasn't able to set up unit tests for these methods yet, I’ve confirmed they work correctly on my local machine.

Since I’m still new to the project, I don’t have full mastery of the codebase yet, so any feedback or suggestions would be greatly appreciated! Thanks so much for your patience and support.

GatienFrenchDev avatar Nov 10 '24 19:11 GatienFrenchDev