import formData from "npm:form-data@4.0.0";
import Mailgun from "npm:mailgun.js@9.1.0";
interface MailgunConfig {
api_key: string;
}
export async function main(
mailgunConfig: MailgunConfig,
domain: string,
from: string,
to: string[],
subject: string,
html: string,
) {
const mailgun = new Mailgun(formData);
const mg = mailgun.client({ username: "api", key: mailgunConfig.api_key });
try {
const result = await mg.messages.create(domain, {
from,
to,
subject,
html,
});
return result;
} catch (error) {
console.error(error);
throw error;
}
}
Submitted by aurélien brabant550 548 days ago