Skip to content
Permalink
4376033244
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
1 contributor

Users who have contributed to this file

29 lines (27 sloc) 671 Bytes
export default async function (
email: string,
sendingKey: string,
subject: string,
template: string,
variables: {
[k: string]: string;
},
) {
const body = new FormData();
body.append("from", "noreply@mail.carcrushers.cc");
body.append("subject", subject);
body.append("template", template);
body.append("to", email);
for (const [name, value] of Object.entries(variables))
body.append(`v:${name}`, value);
return await fetch(
"https://api.mailgun.net/v3/mail.carcrushers.cc/messages",
{
body,
headers: {
authorization: `Basic ${btoa("api" + ":" + sendingKey)}`,
},
method: "POST",
},
);
}