import { email as sendEmail } from "https://esm.town/v/std/email?v=11";
interface VerificationEmailParams {
emailAddress: string;
html: string;
}
export async function sendVerification({ emailAddress, html }: VerificationEmailParams) {
try {
await sendEmail({
to: emailAddress,
from: {
name: "Make It Stick (in 10 days, via email)",
email: "petermillspaugh.sendVerificationEmail@valtown.email",
},
replyTo: "pete@petemillspaugh.com",
subject: "Confirm your subscription to Make It Stick (in 10 days, via email)",
html,
});
await sendEmail({
subject: `${emailAddress} subscribed to Make It Stick (in 10 days, via email)`,
text: `A notification for ${emailAddress} verification should come in any minute now.`,
});
} catch (error) {
const { name, message, stack } = error;
await sendEmail({
subject: `Error sending email verification to ${emailAddress}`,
html: `
<pre>
<code>
${name}
${message}
${stack}
</code>
</pre>
`,
});
}
}