Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1761ebd531 | |||
| 5e5e98601f |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"archiver": "^5.3.1",
|
"archiver": "^5.3.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"description": "Backend for PicPeak event photo sharing platform",
|
"description": "Backend for PicPeak event photo sharing platform",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -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.' });
|
return res.status(400).json({ error: 'Email configuration not found. Please configure SMTP settings first.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create transporter
|
// Validate SMTP configuration
|
||||||
const transporter = nodemailer.createTransport({
|
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,
|
host: config.smtp_host,
|
||||||
port: config.smtp_port,
|
port: parseInt(config.smtp_port),
|
||||||
secure: config.smtp_secure,
|
secure: config.smtp_secure === true || config.smtp_secure === 1,
|
||||||
auth: config.smtp_user ? {
|
auth: config.smtp_user && config.smtp_pass ? {
|
||||||
user: config.smtp_user,
|
user: config.smtp_user,
|
||||||
pass: config.smtp_pass
|
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
|
// Send test email
|
||||||
await transporter.sendMail({
|
await transporter.sendMail({
|
||||||
from: `${config.from_name} <${config.from_email}>`,
|
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' });
|
res.json({ message: 'Test email sent successfully' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Test email error:', 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({
|
res.status(500).json({
|
||||||
error: 'Failed to send test email',
|
error: errorMessage,
|
||||||
details: error.message
|
details: details,
|
||||||
|
code: error.code
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.0.0",
|
"@tanstack/react-query": "^5.0.0",
|
||||||
"@tiptap/extension-link": "^2.25.0",
|
"@tiptap/extension-link": "^2.25.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
Reference in New Issue
Block a user