diff --git a/.env.example b/.env.example index 56747a1..cb06d30 100644 --- a/.env.example +++ b/.env.example @@ -9,12 +9,14 @@ DATABASE_URL=postgresql://votc:votc_password@localhost:5432/votc # ============================================ -# Resend API for emails +# SMTP Email (Mailcow) # ============================================ -# Get from: https://resend.com/api-keys -RESEND_API_KEY=re_xxxxxxxxxxxxx +SMTP_HOST=mx.jeffemmett.com +SMTP_PORT=587 +SMTP_USER=noreply@jeffemmett.com +SMTP_PASS=changeme -# Email sender address (must be verified in Resend) +# Email sender address EMAIL_FROM=Valley of the Commons # ============================================ diff --git a/api/application.js b/api/application.js index aaf4f68..f2e3f61 100644 --- a/api/application.js +++ b/api/application.js @@ -110,12 +110,12 @@ const adminNotificationEmail = (application) => ({ ` }); -async function logEmail(recipientEmail, recipientName, emailType, subject, resendId, metadata = {}) { +async function logEmail(recipientEmail, recipientName, emailType, subject, messageId, metadata = {}) { try { await pool.query( - `INSERT INTO email_log (recipient_email, recipient_name, email_type, subject, resend_id, metadata) + `INSERT INTO email_log (recipient_email, recipient_name, email_type, subject, message_id, metadata) VALUES ($1, $2, $3, $4, $5, $6)`, - [recipientEmail, recipientName, emailType, subject, resendId, JSON.stringify(metadata)] + [recipientEmail, recipientName, emailType, subject, messageId, JSON.stringify(metadata)] ); } catch (error) { console.error('Failed to log email:', error); diff --git a/api/waitlist-db.js b/api/waitlist-db.js index fbfa008..fea033a 100644 --- a/api/waitlist-db.js +++ b/api/waitlist-db.js @@ -65,12 +65,12 @@ const welcomeEmail = (signup) => ({ ` }); -async function logEmail(recipientEmail, recipientName, emailType, subject, resendId, metadata = {}) { +async function logEmail(recipientEmail, recipientName, emailType, subject, messageId, metadata = {}) { try { await pool.query( - `INSERT INTO email_log (recipient_email, recipient_name, email_type, subject, resend_id, metadata) + `INSERT INTO email_log (recipient_email, recipient_name, email_type, subject, message_id, metadata) VALUES ($1, $2, $3, $4, $5, $6)`, - [recipientEmail, recipientName, emailType, subject, resendId, JSON.stringify(metadata)] + [recipientEmail, recipientName, emailType, subject, messageId, JSON.stringify(metadata)] ); } catch (error) { console.error('Failed to log email:', error); diff --git a/db/schema.sql b/db/schema.sql index 407de27..d9d4d3b 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -106,7 +106,7 @@ CREATE TABLE IF NOT EXISTS email_log ( recipient_name VARCHAR(255), email_type VARCHAR(100) NOT NULL, -- application_confirmation, waitlist_welcome, status_update, etc subject VARCHAR(500), - resend_id VARCHAR(255), -- Resend API message ID + message_id VARCHAR(255), -- SMTP message ID status VARCHAR(50) DEFAULT 'sent', -- sent, delivered, bounced, failed sent_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, metadata JSONB diff --git a/docker-compose.yml b/docker-compose.yml index 8f5d4b0..74084ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,10 @@ services: restart: unless-stopped environment: - DATABASE_URL=postgresql://votc:votc_password@votc-db:5432/votc - - RESEND_API_KEY=${RESEND_API_KEY} + - SMTP_HOST=${SMTP_HOST} + - SMTP_PORT=${SMTP_PORT} + - SMTP_USER=${SMTP_USER} + - SMTP_PASS=${SMTP_PASS} - EMAIL_FROM=Valley of the Commons - ADMIN_API_KEY=${ADMIN_API_KEY} - ADMIN_EMAILS=${ADMIN_EMAILS:-jeff@jeffemmett.com}