Skip to content

Commit 9fd15b2

Browse files
committed
Send an email with React Email, Sidecar, and Resend
1 parent d1cbaab commit 9fd15b2

File tree

8 files changed

+2809
-0
lines changed

8 files changed

+2809
-0
lines changed

app/Mail/TestMail.php

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace App\Mail;
4+
5+
use App\Sidecar\RenderEmail;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
10+
use Illuminate\Queue\SerializesModels;
11+
12+
class TestMail extends Mailable
13+
{
14+
use Queueable;
15+
use SerializesModels;
16+
17+
/**
18+
* Create a new message instance.
19+
*/
20+
public function __construct()
21+
{
22+
}
23+
24+
/**
25+
* Get the message envelope.
26+
*/
27+
public function envelope(): Envelope
28+
{
29+
return new Envelope(
30+
subject: 'Test Mail',
31+
);
32+
}
33+
34+
/**
35+
* Get the message content definition.
36+
*/
37+
public function content(): Content
38+
{
39+
return new Content(
40+
htmlString: RenderEmail::execute()->body()
41+
);
42+
}
43+
44+
/**
45+
* Get the attachments for the message.
46+
*
47+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
48+
*/
49+
public function attachments(): array
50+
{
51+
return [];
52+
}
53+
}

app/Sidecar/RenderEmail.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Sidecar;
4+
5+
use Hammerstone\Sidecar\LambdaFunction;
6+
use Hammerstone\Sidecar\Package;
7+
8+
class RenderEmail extends LambdaFunction
9+
{
10+
public function handler(): string
11+
{
12+
return 'dist/render-email.handle';
13+
}
14+
15+
public function runtime()
16+
{
17+
return 'nodejs20.x';
18+
}
19+
20+
public function package()
21+
{
22+
return Package::make()
23+
->setBasePath(resource_path('sidecar/render-email'))
24+
->include(['node_modules', 'dist', 'package.json']);
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+

0 commit comments

Comments
 (0)