Compare commits

...

2 Commits

Author SHA1 Message Date
Gitea Actions Bot 1761ebd531 chore: bump version to 1.0.20
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-07-14 10:08:49 +00:00
paul 5e5e98601f fix: improve email test endpoint error handling
Test and Lint / backend-test (push) Successful in 1m10s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m6s
Version and Release / version-bump (push) Successful in 32s
Version and Release / trigger-drone (push) Successful in 3s
- Add detailed validation for SMTP configuration
- Add specific error messages for common SMTP issues (connection, auth, network)
- Add logging to help debug email configuration issues
- Check for masked passwords that shouldn't be used for sending
- Parse smtp_port as integer and handle boolean smtp_secure properly

This helps identify the exact cause of email sending failures instead of
generic 500 errors.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-14 12:04:57 +02:00
5 changed files with 59 additions and 14 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "picpeak-backend",
"version": "1.0.19",
"version": "1.0.20",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "picpeak-backend",
"version": "1.0.19",
"version": "1.0.20",
"dependencies": {
"adm-zip": "^0.5.16",
"archiver": "^5.3.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "picpeak-backend",
"version": "1.0.19",
"version": "1.0.20",
"description": "Backend for PicPeak event photo sharing platform",
"main": "server.js",
"scripts": {
+53 -8
View File
@@ -112,17 +112,44 @@ router.post('/test', adminAuth, async (req, res) => {
return res.status(400).json({ error: 'Email configuration not found. Please configure SMTP settings first.' });
}
// Create transporter
const transporter = nodemailer.createTransport({
// Validate SMTP configuration
if (!config.smtp_host || !config.smtp_port) {
return res.status(400).json({
error: 'Incomplete email configuration',
details: 'SMTP host and port are required'
});
}
// Check if password might be masked (this shouldn't happen when fetching from DB)
if (config.smtp_pass === '********') {
return res.status(400).json({
error: 'Invalid email configuration',
details: 'SMTP password appears to be masked. Please reconfigure your email settings.'
});
}
// Create transporter with detailed logging
const transportConfig = {
host: config.smtp_host,
port: config.smtp_port,
secure: config.smtp_secure,
auth: config.smtp_user ? {
port: parseInt(config.smtp_port),
secure: config.smtp_secure === true || config.smtp_secure === 1,
auth: config.smtp_user && config.smtp_pass ? {
user: config.smtp_user,
pass: config.smtp_pass
} : undefined
} : undefined,
logger: process.env.NODE_ENV === 'development',
debug: process.env.NODE_ENV === 'development'
};
console.log('Creating email transporter with config:', {
host: transportConfig.host,
port: transportConfig.port,
secure: transportConfig.secure,
auth: transportConfig.auth ? 'configured' : 'none'
});
const transporter = nodemailer.createTransport(transportConfig);
// Send test email
await transporter.sendMail({
from: `${config.from_name} <${config.from_email}>`,
@@ -145,9 +172,27 @@ router.post('/test', adminAuth, async (req, res) => {
res.json({ message: 'Test email sent successfully' });
} catch (error) {
console.error('Test email error:', error);
console.error('Error stack:', error.stack);
// Provide more specific error messages
let errorMessage = 'Failed to send test email';
let details = error.message;
if (error.code === 'ECONNREFUSED') {
errorMessage = 'Failed to connect to SMTP server';
details = 'Please check your SMTP host and port settings';
} else if (error.code === 'EAUTH') {
errorMessage = 'SMTP authentication failed';
details = 'Please check your SMTP username and password';
} else if (error.code === 'ESOCKET') {
errorMessage = 'Network error';
details = 'Could not establish connection to SMTP server';
}
res.status(500).json({
error: 'Failed to send test email',
details: error.message
error: errorMessage,
details: details,
code: error.code
});
}
});
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "picpeak-frontend",
"version": "1.0.19",
"version": "1.0.20",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "picpeak-frontend",
"version": "1.0.19",
"version": "1.0.20",
"dependencies": {
"@tanstack/react-query": "^5.0.0",
"@tiptap/extension-link": "^2.25.0",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "picpeak-frontend",
"private": true,
"version": "1.0.19",
"version": "1.0.20",
"type": "module",
"scripts": {
"dev": "vite",