blob: 9fe7bec50e87b9b744a499fd7b64ee781ceb5e89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2";
import { AwsContext } from "../aws.ts";
import { Mail } from "../mail.ts";
import { MailDeliverer } from "../deliver.ts";
export class AwsMailDeliverer extends MailDeliverer {
private _ses;
constructor(readonly aws: AwsContext) {
super("aws");
const { region, credentials } = aws;
this._ses = new SESv2Client({ region, credentials });
}
protected override async doDeliver(mail: Mail): Promise<void> {
const sendCommand = new SendEmailCommand({
Content: {
Raw: { Data: mail.encodeUtf8() },
},
});
const res = await this._ses.send(sendCommand);
if (res.MessageId == null) {
throw Error("No message id is returned from aws.");
}
mail.aws_message_id = res.MessageId;
}
}
|