import * as wmill from "https://deno.land/x/windmill@v1.120.0/mod.ts";
import formData from "npm:form-data@4.0.0";
import Mailgun from "npm:mailgun.js@9.1.0";
// fill the type, or use the +Resource type to get a type-safe reference to a resource
// type Postgresql = object
export async function main(
mailgunConfig: wmill.Resource<"mailgun">,
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 687 days ago