Both containers now run in network_mode: host so the API can connect directly to Proton Bridge on 127.0.0.1:1025. The pfSense search domain (home.arpa) was leaking into Docker DNS and causing NXDOMAIN failures for inter-container hostnames. Host networking bypasses this entirely. - docker-compose: both services use network_mode: host - nginx: listen on 8080 (was 80), proxy /api/ to 127.0.0.1:3001 - server.js: allow self-signed TLS cert from Proton Bridge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
const express = require('express')
|
|
const nodemailer = require('nodemailer')
|
|
const cors = require('cors')
|
|
|
|
const app = express()
|
|
app.use(cors())
|
|
app.use(express.json())
|
|
|
|
const transporter = nodemailer.createTransport({
|
|
host: process.env.SMTP_HOST,
|
|
port: parseInt(process.env.SMTP_PORT || '587'),
|
|
secure: process.env.SMTP_SECURE === 'true',
|
|
auth: {
|
|
user: process.env.SMTP_USER,
|
|
pass: process.env.SMTP_PASS,
|
|
},
|
|
tls: { rejectUnauthorized: false },
|
|
})
|
|
|
|
app.post('/contact', async (req, res) => {
|
|
const { name, email, service, message } = req.body
|
|
|
|
if (!name || !email || !message) {
|
|
return res.status(400).json({ error: 'Name, email, and message are required.' })
|
|
}
|
|
|
|
try {
|
|
await transporter.sendMail({
|
|
from: `"KenJim Technologies" <${process.env.SMTP_USER}>`,
|
|
to: process.env.CONTACT_TO,
|
|
replyTo: email,
|
|
subject: `[kenjim.com] ${service || 'General Inquiry'} — ${name}`,
|
|
text: `Name: ${name}\nEmail: ${email}\nService: ${service || 'General Inquiry'}\n\n${message}`,
|
|
html: `
|
|
<p><strong>Name:</strong> ${name}</p>
|
|
<p><strong>Email:</strong> <a href="mailto:${email}">${email}</a></p>
|
|
<p><strong>Service:</strong> ${service || 'General Inquiry'}</p>
|
|
<hr/>
|
|
<p>${message.replace(/\n/g, '<br>')}</p>
|
|
`,
|
|
})
|
|
res.json({ ok: true })
|
|
} catch (err) {
|
|
console.error('Mail error:', err)
|
|
res.status(500).json({ error: 'Failed to send message. Please try again.' })
|
|
}
|
|
})
|
|
|
|
app.listen(3001, () => console.log('API listening on :3001'))
|