11import { render } from "@react-email/render" ;
22import { 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" ;
55
66export type AwsSesMailTransportOptions = {
7- type : ' aws-ses' ,
8- }
7+ type : " aws-ses" ;
8+ } ;
99
1010export class AwsSesMailTransport implements MailTransport {
1111 #client: nodemailer . Transporter ;
1212
1313 constructor ( options : AwsSesMailTransportOptions ) {
14- const ses = new awsSes . SESClient ( )
14+ const ses = new awsSes . SESClient ( ) ;
1515
1616 this . #client = nodemailer . createTransport ( {
1717 SES : {
1818 aws : awsSes ,
19- ses
20- }
21- } )
19+ ses,
20+ } ,
21+ } ) ;
2222 }
2323
24- async send ( { to, from, replyTo, subject, react} : MailMessage ) : Promise < void > {
24+ async send ( { to, from, replyTo, subject, react } : MailMessage ) : Promise < void > {
2525 try {
2626 await this . #client. sendMail ( {
2727 from : from ,
2828 to,
2929 replyTo : replyTo ,
3030 subject,
31- html : render ( react ) ,
31+ html : await render ( react ) ,
3232 } ) ;
33- }
34- catch ( error ) {
33+ } catch ( error ) {
3534 if ( error instanceof Error ) {
3635 console . error (
3736 `Failed to send email to ${ to } , ${ subject } . Error ${ error . name } : ${ error . message } `
@@ -43,7 +42,7 @@ export class AwsSesMailTransport implements MailTransport {
4342 }
4443 }
4544
46- async sendPlainText ( { to, from, replyTo, subject, text} : PlainTextMailMessage ) : Promise < void > {
45+ async sendPlainText ( { to, from, replyTo, subject, text } : PlainTextMailMessage ) : Promise < void > {
4746 try {
4847 await this . #client. sendMail ( {
4948 from : from ,
@@ -52,8 +51,7 @@ export class AwsSesMailTransport implements MailTransport {
5251 subject,
5352 text : text ,
5453 } ) ;
55- }
56- catch ( error ) {
54+ } catch ( error ) {
5755 if ( error instanceof Error ) {
5856 console . error (
5957 `Failed to send email to ${ to } , ${ subject } . Error ${ error . name } : ${ error . message } `
0 commit comments