import formData from "npm:form-data@4.0.0";
import MailgunClient from "npm:mailgun.js@9.1.0";
interface Mailgun {
api_key: string;
}
export async function main(
mailgunConfig: Mailgun,
domain: string,
from: string,
to: string[],
subject: string,
templateName: string,
replyTo?: string,
substitutions: Record<string, string>,
) {
const mailgun = new MailgunClient(formData);
const mg = mailgun.client({ username: "api", key: mailgunConfig.api_key });
try {
const result = await mg.messages.create(domain, {
from,
to,
subject,
template: templateName,
"h:X-Mailgun-Variables": JSON.stringify(substitutions),
...(replyTo && { "h:Reply-To": replyTo }),
});
return result;
} catch (error) {
console.error(error);
throw error;
}
}
Submitted by admin 480 days ago
import formData from "npm:form-data@4.0.0";
import MailgunClient from "npm:mailgun.js@9.1.0";
interface Mailgun {
api_key: string;
}
export async function main(
mailgunConfig: Mailgun,
domain: string,
from: string,
to: string[],
subject: string,
templateName: string,
replyTo?: string,
substitutions: Record<string, string>
) {
const mailgun = new MailgunClient(formData);
const mg = mailgun.client({ username: "api", key: mailgunConfig.api_key });
try {
const result = await mg.messages.create(domain, {
from,
to,
subject,
template: templateName,
'h:X-Mailgun-Variables': JSON.stringify(substitutions),
...(replyTo && { 'h:Reply-To': replyTo })
});
return result;
} catch (error) {
console.error(error);
throw error;
}
}
Submitted by rubenfiszel 532 days ago
import formData from "npm:form-data@4.0.0";
import Mailgun from "npm:mailgun.js@9.1.0";
interface Mailgun {
api_key: string;
}
export async function main(
mailgunConfig: Mailgun,
domain: string,
from: string,
to: string[],
subject: string,
templateName: string,
replyTo?: string,
substitutions: Record<string, 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,
template: templateName,
'h:X-Mailgun-Variables': JSON.stringify(substitutions),
...(replyTo && { 'h:Reply-To': replyTo })
});
return result;
} catch (error) {
console.error(error);
throw error;
}
}
Submitted by rubenfiszel 532 days ago
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,
templateName: string,
replyTo?: string,
substitutions: Record<string, 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,
template: templateName,
'h:X-Mailgun-Variables': JSON.stringify(substitutions),
...(replyTo && { 'h:Reply-To': replyTo })
});
return result;
} catch (error) {
console.error(error);
throw error;
}
}
Submitted by aurélien brabant550 532 days ago