1
1
import { render } from "@react-email/render" ;
2
2
import { EmailError , MailMessage , MailTransport , PlainTextMailMessage } from "./index" ;
3
- import nodemailer from "nodemailer"
4
- import * as awsSes from "@aws-sdk/client-ses"
3
+ import nodemailer from "nodemailer" ;
4
+ import * as awsSes from "@aws-sdk/client-ses" ;
5
5
6
6
export type AwsSesMailTransportOptions = {
7
- type : ' aws-ses' ,
8
- }
7
+ type : " aws-ses" ;
8
+ } ;
9
9
10
10
export class AwsSesMailTransport implements MailTransport {
11
11
#client: nodemailer . Transporter ;
12
12
13
13
constructor ( options : AwsSesMailTransportOptions ) {
14
- const ses = new awsSes . SESClient ( )
14
+ const ses = new awsSes . SESClient ( ) ;
15
15
16
16
this . #client = nodemailer . createTransport ( {
17
17
SES : {
18
18
aws : awsSes ,
19
- ses
20
- }
21
- } )
19
+ ses,
20
+ } ,
21
+ } ) ;
22
22
}
23
23
24
- async send ( { to, from, replyTo, subject, react} : MailMessage ) : Promise < void > {
24
+ async send ( { to, from, replyTo, subject, react } : MailMessage ) : Promise < void > {
25
25
try {
26
26
await this . #client. sendMail ( {
27
27
from : from ,
28
28
to,
29
29
replyTo : replyTo ,
30
30
subject,
31
- html : render ( react ) ,
31
+ html : await render ( react ) ,
32
32
} ) ;
33
- }
34
- catch ( error ) {
33
+ } catch ( error ) {
35
34
if ( error instanceof Error ) {
36
35
console . error (
37
36
`Failed to send email to ${ to } , ${ subject } . Error ${ error . name } : ${ error . message } `
@@ -43,7 +42,7 @@ export class AwsSesMailTransport implements MailTransport {
43
42
}
44
43
}
45
44
46
- async sendPlainText ( { to, from, replyTo, subject, text} : PlainTextMailMessage ) : Promise < void > {
45
+ async sendPlainText ( { to, from, replyTo, subject, text } : PlainTextMailMessage ) : Promise < void > {
47
46
try {
48
47
await this . #client. sendMail ( {
49
48
from : from ,
@@ -52,8 +51,7 @@ export class AwsSesMailTransport implements MailTransport {
52
51
subject,
53
52
text : text ,
54
53
} ) ;
55
- }
56
- catch ( error ) {
54
+ } catch ( error ) {
57
55
if ( error instanceof Error ) {
58
56
console . error (
59
57
`Failed to send email to ${ to } , ${ subject } . Error ${ error . name } : ${ error . message } `
0 commit comments