import nodemailer from 'nodemailer';
// Import just the template helper without hitting DB
// We'll construct the email manually since the DB connection fails
const BRAND = {
red: '#de0f1e',
darkBlue: '#053d57',
white: '#fefefe',
teal: '#557f8c',
};
const token = '6f974b1da9fae95f74bbcd2419df589730979ac945aeaa5413021c00311b5165';
const url = 'http://localhost:3000/accept-invite?token=' + token;
// Replicate the styled email template from email.ts
function getStyledHtml(name: string, inviteUrl: string) {
return `
You're invited to join the MOPC Portal
Monaco Ocean Protection Challenge
Together for a healthier ocean
|
Hello ${name},
You've been invited to join the Monaco Ocean Protection Challenge platform as an applicant.
Click the button below to set up your account and get started.
|
This link will expire in 3 days.
|
|
|
Monaco Ocean Protection Challenge
Together for a healthier ocean.
|
|
`;
}
async function main() {
console.log('Creating transporter...');
const transporter = nodemailer.createTransport({
host: 'mail.monaco-opc.com',
port: 587,
secure: false,
auth: {
user: 'noreply@monaco-opc.com',
pass: '9EythPDcz1Fya4M88iigkB1wojNf8QEVPuRRnD9dJMBpT3pk2',
},
});
console.log('Sending styled invitation email...');
const info = await transporter.sendMail({
from: 'MOPC Portal ',
to: 'matt.ciaccio@gmail.com',
subject: "You're invited to join the MOPC Portal",
text: `Hello Matt Ciaccio,\n\nYou've been invited to join the Monaco Ocean Protection Challenge platform as an applicant.\n\nClick the link below to set up your account:\n\n${url}\n\nThis link will expire in 3 days.\n\n---\nMonaco Ocean Protection Challenge\nTogether for a healthier ocean.`,
html: getStyledHtml('Matt Ciaccio', url),
});
console.log('SUCCESS! Message ID:', info.messageId);
process.exit(0);
}
main().catch(err => {
console.error('FAILED:', err);
process.exit(1);
});