Muhammed Sameer
Initial commit - Iris Full (under development)
ea9ca44
// supabase/functions/send-interview-email/index.ts
import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { Resend } from "npm:resend";
const resend = new Resend(Deno.env.get("RESEND_API_KEY"));
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
};
serve(async (req) => {
if (req.method === "OPTIONS") return new Response("ok", { headers: corsHeaders });
try {
const { candidateName, candidateEmail, date, time, meetingLink, role } = await req.json();
const { data, error } = await resend.emails.send({
from: "Acme HR <onboarding@resend.dev>", // Change this to your verified domain if you have one
to: [candidateEmail],
subject: `Interview Invitation: ${role}`,
html: `
<div style="font-family: sans-serif; padding: 20px;">
<h1>Hi ${candidateName},</h1>
<p>We are pleased to invite you to a <strong>Technical Interview</strong> for the <strong>${role}</strong> position.</p>
<div style="background: #f3f4f6; padding: 15px; border-radius: 8px; margin: 20px 0;">
<p style="margin: 5px 0;"><strong>πŸ“… Date:</strong> ${date}</p>
<p style="margin: 5px 0;"><strong>⏰ Time:</strong> ${time}</p>
<p style="margin: 5px 0;"><strong>πŸ”— Link:</strong> <a href="${meetingLink}">${meetingLink}</a></p>
</div>
<p>Please join 5 minutes early.</p>
<p>Best,<br>Hiring Team</p>
</div>
`,
});
if (error) throw error;
return new Response(JSON.stringify(data), {
headers: { ...corsHeaders, "Content-Type": "application/json" },
status: 200,
});
} catch (error) {
return new Response(JSON.stringify({ error: error.message }), {
headers: { ...corsHeaders, "Content-Type": "application/json" },
status: 500,
});
}
});