Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 32 33 34 35 36 | 51x 51x 53x 53x 53x 18x 18x 35x 35x | import { Resend } from "resend";
import type { EmailProvider, EmailConfig } from "./base";
export class ResendProvider implements EmailProvider {
private resend: Resend;
private from: string;
constructor(apiKey: string, config: EmailConfig) {
this.resend = new Resend(apiKey);
this.from = config.from;
}
async sendEmail(params: {
to: string;
subject: string;
html: string;
}): Promise<{ id: string }> {
const { to, subject, html } = params;
const { data, error } = await this.resend.emails.send({
from: this.from,
to,
subject,
html,
});
if (error) {
console.error("[EMAIL-RESEND] Failed to send:", error);
throw new Error(`Failed to send email: ${error.message}`);
}
console.log(`[EMAIL-RESEND] Email sent to ${to}: ${subject}`);
return { id: data?.id || "unknown" };
}
}
|