Skip to content

Commit

Permalink
Send an email with React Email, Sidecar, and Resend
Browse files Browse the repository at this point in the history
  • Loading branch information
owenconti committed Apr 20, 2024
1 parent d1cbaab commit 9fd15b2
Show file tree
Hide file tree
Showing 8 changed files with 2,809 additions and 0 deletions.
53 changes: 53 additions & 0 deletions app/Mail/TestMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Mail;

use App\Sidecar\RenderEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class TestMail extends Mailable
{
use Queueable;
use SerializesModels;

/**
* Create a new message instance.
*/
public function __construct()
{
}

/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'Test Mail',
);
}

/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
htmlString: RenderEmail::execute()->body()
);
}

/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}
26 changes: 26 additions & 0 deletions app/Sidecar/RenderEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Sidecar;

use Hammerstone\Sidecar\LambdaFunction;
use Hammerstone\Sidecar\Package;

class RenderEmail extends LambdaFunction
{
public function handler(): string
{
return 'dist/render-email.handle';
}

public function runtime()
{
return 'nodejs20.x';
}

public function package()
{
return Package::make()
->setBasePath(resource_path('sidecar/render-email'))
->include(['node_modules', 'dist', 'package.json']);
}
}
3 changes: 3 additions & 0 deletions resources/sidecar/render-email/dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore

Loading

0 comments on commit 9fd15b2

Please sign in to comment.