import nodemailer from 'nodemailer'; // Create reusable transporter object using SMTP transport const transporter = nodemailer.createTransport({ service: 'iCloud', secure: false, auth: { user: 'soconnor0919@icloud.com', pass: 'uhlb-virv-qqpk-puwc', }, }); // Verify connection configuration transporter.verify(function(error, success) { if (error) { console.log('SMTP Verification Error:', error); } }); interface SendInvitationEmailParams { to: string; inviterName: string; studyTitle: string; role: string; token: string; } export async function sendInvitationEmail({ to, inviterName, studyTitle, role, token, }: SendInvitationEmailParams) { const inviteUrl = `${process.env.NEXT_PUBLIC_APP_URL}/invite/accept/${token}`; const roleDisplay = role .split('_') .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(' '); const html = ` HRIStudio Invitation

HRI Studio

A platform for managing human-robot interaction studies

You've been invited to join a research study

${inviterName} has invited you to join "${studyTitle}" as a ${roleDisplay}.

HRIStudio helps research teams manage human-robot interaction studies and conduct Wizard-of-Oz experiments efficiently.

Accept Invitation

If you're having trouble with the button above, copy and paste the URL below into your web browser:

${inviteUrl}

This invitation will expire in 7 days.

This is an automated message from HRIStudio. Please do not reply to this email.

`; const text = ` You've been invited to join HRIStudio ${inviterName} has invited you to join "${studyTitle}" as a ${roleDisplay}. HRIStudio helps research teams manage human-robot interaction studies and conduct Wizard-of-Oz experiments efficiently. To accept the invitation, visit this URL: ${inviteUrl} This invitation will expire in 7 days. `; await transporter.sendMail({ from: `"HRIStudio" <${process.env.SMTP_FROM_ADDRESS}>`, to, subject: `Invitation to join "${studyTitle}" on HRIStudio`, text, html, }); }