Compare commits
1 Commits
af91dba268
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 04c420d255 |
@@ -640,6 +640,28 @@ app.get('/api/health', async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// ─── EMAIL TEST ─────────────────────────────────────────────────
|
||||
|
||||
app.post('/api/admin/test-email', requireAuth, async (req, res) => {
|
||||
if (req.session.userRole !== 'superadmin') return res.status(403).json({ error: 'Superadmin only' });
|
||||
const to = req.body.to || req.session.userEmail;
|
||||
if (!to) return res.status(400).json({ error: 'No recipient — pass { "to": "email@example.com" }' });
|
||||
const { sendMail, getSmtpConfig } = require('./mail');
|
||||
const config = getSmtpConfig();
|
||||
if (!config) return res.status(503).json({ error: 'SMTP not configured', env: { server: !!process.env.CLOUDRON_MAIL_SMTP_SERVER || !!process.env.MAIL_SMTP_SERVER } });
|
||||
try {
|
||||
const info = await sendMail({
|
||||
to,
|
||||
subject: 'Rawaj — Test Email',
|
||||
html: '<p>If you received this, email delivery is working correctly.</p>',
|
||||
text: 'If you received this, email delivery is working correctly.',
|
||||
});
|
||||
res.json({ success: true, to, messageId: info?.messageId, smtp: { host: config.host, port: config.port, from: config.from } });
|
||||
} catch (err) {
|
||||
res.status(500).json({ success: false, error: err.message, code: err.code, smtp: { host: config.host, port: config.port } });
|
||||
}
|
||||
});
|
||||
|
||||
// ─── SETUP ROUTES ───────────────────────────────────────────────
|
||||
|
||||
app.get('/api/setup/status', async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user