diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml deleted file mode 100644 index 2ac3fc0..0000000 --- a/.github/workflows/actions.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: GitHub Actions - -on: - pull_request: - branches: - - main - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: - - 18 - - 20 - - 22 - steps: - - uses: actions/checkout@v4 - - name: Use Node.js v${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - run: npm ci - - run: npm run build - # - run: npm test - - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Use Node.js 22 - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: npm - - run: npm ci - - run: npm run check diff --git a/check-email-delivery.cjs b/check-email-delivery.cjs deleted file mode 100644 index fa86721..0000000 --- a/check-email-delivery.cjs +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Email Delivery Test Script - * - * This script tests email delivery by sending test emails to different addresses - * and with different configurations to help diagnose delivery issues. - */ - -const nodemailer = require('nodemailer'); -require('dotenv').config(); - -// Environment variables -const { - SMTP_HOST = 'smtp.protonmail.ch', - SMTP_PORT = '587', - SMTP_USER = '', - SMTP_PASS = '', - ADMIN_EMAIL = 'richard@bergsma.it', - WEBSITE_NAME = 'bergsma.it', - NODE_ENV = 'development' -} = process.env; - -// Set to production mode for this test -const isProduction = true; - -console.log('Email Delivery Test'); -console.log('------------------'); -console.log('Configuration:'); -console.log(`SMTP Host: ${SMTP_HOST}`); -console.log(`SMTP Port: ${SMTP_PORT}`); -console.log(`SMTP User: ${SMTP_USER}`); -console.log(`Admin Email: ${ADMIN_EMAIL}`); -console.log(`Website Name: ${WEBSITE_NAME}`); -console.log(`Mode: ${isProduction ? 'production' : 'development'}`); -console.log('------------------'); - -// Create a transporter -const transporter = nodemailer.createTransport({ - host: SMTP_HOST, - port: parseInt(SMTP_PORT, 10), - secure: parseInt(SMTP_PORT, 10) === 465, - auth: { - user: SMTP_USER, - pass: SMTP_PASS, - }, - tls: { - rejectUnauthorized: false, - ciphers: 'SSLv3' - }, - debug: true -}); - -// Verify connection -console.log('Testing SMTP connection...'); -transporter.verify(function(error, success) { - if (error) { - console.error('SMTP Connection Error:', error); - process.exit(1); - } - - console.log('SMTP Connection Successful!'); - runTests(); -}); - -// Run a series of email delivery tests -async function runTests() { - try { - // Test 1: Basic email to admin - console.log('\nTest 1: Sending basic email to admin...'); - await sendTestEmail( - ADMIN_EMAIL, - 'Email Delivery Test 1 - Basic', - 'This is a basic test email to the admin address.', - `

This is a basic test email to the admin address.

Time: ${new Date().toISOString()}

` - ); - - // Test 2: Email with different From address - console.log('\nTest 2: Sending email with different From address...'); - await sendTestEmail( - ADMIN_EMAIL, - 'Email Delivery Test 2 - Different From', - 'This email uses a different From address.', - `

This email uses a different From address.

Time: ${new Date().toISOString()}

`, - `"Test Sender" <${SMTP_USER}>` - ); - - // Test 3: Email with contact form format - console.log('\nTest 3: Sending email in contact form format...'); - const contactFormHtml = ` -
-

New Contact Form Submission

-

From: Test User (test@example.com)

-

Submitted on: ${new Date().toLocaleString()}

-
-

Message:

-

This is a test message simulating a contact form submission.

-
-
-

This is an automated email from your website contact form.

-
-
- `; - await sendTestEmail( - ADMIN_EMAIL, - 'New Contact Form Submission (Test)', - 'This is a test message simulating a contact form submission.', - contactFormHtml - ); - - console.log('\nAll tests completed successfully!'); - console.log('\nPlease check your inbox (and spam folder) for the test emails.'); - console.log('If you received some emails but not others, this can help identify the issue.'); - - } catch (error) { - console.error('Error running tests:', error); - } -} - -// Helper function to send a test email -async function sendTestEmail(to, subject, text, html, from = `"${WEBSITE_NAME}" <${ADMIN_EMAIL}>`) { - try { - const info = await transporter.sendMail({ - from, - to, - subject, - text, - html - }); - - console.log(`Email sent successfully!`); - console.log(`Message ID: ${info.messageId}`); - console.log(`Response: ${info.response}`); - return info; - } catch (error) { - console.error('Error sending email:', error); - throw error; - } -} \ No newline at end of file diff --git a/email-test.cjs b/email-test.cjs deleted file mode 100644 index 8e04555..0000000 --- a/email-test.cjs +++ /dev/null @@ -1,101 +0,0 @@ -/** - * ProtonMail SMTP Test Script - * - * This script tests the SMTP configuration for sending emails through ProtonMail. - * Run with: node email-test.cjs - */ - -const nodemailer = require('nodemailer'); -require('dotenv').config(); - -// Get SMTP settings from environment variables -const { - SMTP_HOST = 'smtp.protonmail.ch', - SMTP_PORT = '587', - SMTP_USER, - SMTP_PASS, - ADMIN_EMAIL, - WEBSITE_NAME = 'Website' -} = process.env; - -console.log('Email Configuration Test'); -console.log('----------------------'); -console.log(`SMTP Host: ${SMTP_HOST}`); -console.log(`SMTP Port: ${SMTP_PORT}`); -console.log(`SMTP User: ${SMTP_USER}`); -console.log(`Admin Email: ${ADMIN_EMAIL}`); -console.log(`Environment: ${process.env.NODE_ENV || 'development'}`); -console.log('----------------------'); - -// Create a transporter with ProtonMail-specific settings -const transporter = nodemailer.createTransport({ - host: SMTP_HOST, - port: parseInt(SMTP_PORT, 10), - secure: parseInt(SMTP_PORT, 10) === 465, // true for 465, false for other ports - auth: { - user: SMTP_USER, - pass: SMTP_PASS, - }, - tls: { - // Do not fail on invalid certs - rejectUnauthorized: false, - // Specific ciphers for ProtonMail - ciphers: 'SSLv3' - }, - debug: true // Enable debug output -}); - -// Test the connection -console.log('Testing SMTP connection...'); -transporter.verify((error, success) => { - if (error) { - console.error('SMTP Connection Error:', error); - console.error('\nTroubleshooting Tips:'); - console.error('1. Check if your SMTP credentials are correct'); - console.error('2. For ProtonMail, ensure you\'re using an app-specific password'); - console.error('3. If using ProtonMail Bridge, make sure it\'s running'); - console.error('4. Verify your server allows outgoing connections on the SMTP port'); - process.exit(1); - } else { - console.log('SMTP Connection Successful!'); - - // Send a test email - console.log('\nSending a test email...'); - const mailOptions = { - from: `"${WEBSITE_NAME}" <${SMTP_USER}>`, - to: ADMIN_EMAIL, - subject: 'Email Configuration Test', - text: 'This is a test email to verify your website\'s email configuration is working correctly.', - html: ` -
-

Email Configuration Test

-

This is a test email to verify your website's email configuration is working correctly.

-

Configuration Details:

- -

- This is an automated test email. If you received this, your email configuration is working correctly. -

-
- ` - }; - - transporter.sendMail(mailOptions, (error, info) => { - if (error) { - console.error('Error sending test email:', error); - process.exit(1); - } else { - console.log('Test email sent successfully!'); - console.log('Message ID:', info.messageId); - console.log('Response:', info.response); - console.log('\nIf you received the test email, your email configuration is working correctly.'); - process.exit(0); - } - }); - } -}); \ No newline at end of file diff --git a/production-email-test.cjs b/production-email-test.cjs deleted file mode 100644 index 4b36cb0..0000000 --- a/production-email-test.cjs +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Production Email Test Script - * - * This script tests email delivery in production mode by sending test emails - * with various configurations to help diagnose delivery issues. - * - * Run with: NODE_ENV=production node production-email-test.cjs - */ - -const nodemailer = require('nodemailer'); -require('dotenv').config(); - -// Environment variables -const { - SMTP_HOST = '', - SMTP_PORT = '587', - SMTP_USER = '', - SMTP_PASS = '', - ADMIN_EMAIL = '', - WEBSITE_NAME = 'bergsma.it', - NODE_ENV = 'production' -} = process.env; - -// Force production mode -const isProduction = true; - -console.log('Production Email Test'); -console.log('--------------------'); -console.log('Configuration:'); -console.log(`SMTP Host: ${SMTP_HOST}`); -console.log(`SMTP Port: ${SMTP_PORT}`); -console.log(`SMTP User: ${SMTP_USER}`); -console.log(`Admin Email: ${ADMIN_EMAIL}`); -console.log(`Website Name: ${WEBSITE_NAME}`); -console.log(`Mode: ${isProduction ? 'production' : 'development'}`); -console.log('--------------------'); - -// Create a transporter -function createTransporter(options = {}) { - const isProtonMail = SMTP_HOST.includes('protonmail'); - - return nodemailer.createTransport({ - host: SMTP_HOST, - port: parseInt(SMTP_PORT, 10), - secure: parseInt(SMTP_PORT, 10) === 465, - auth: { - user: SMTP_USER, - pass: SMTP_PASS, - }, - ...(isProtonMail && { - tls: { - rejectUnauthorized: false, - ciphers: 'SSLv3' - } - }), - debug: true, - ...options - }); -} - -// Test different transporter configurations -async function runTests() { - try { - // Test 1: Basic configuration - console.log('\nTest 1: Basic configuration'); - const transporter1 = createTransporter(); - await testTransporter(transporter1, 'Basic configuration'); - - // Test 2: With secure=false explicitly set - console.log('\nTest 2: With secure=false explicitly set'); - const transporter2 = createTransporter({ secure: false }); - await testTransporter(transporter2, 'secure=false configuration'); - - // Test 3: With requireTLS=true - console.log('\nTest 3: With requireTLS=true'); - const transporter3 = createTransporter({ requireTLS: true }); - await testTransporter(transporter3, 'requireTLS=true configuration'); - - // Test 4: With different from address - console.log('\nTest 4: With different from address'); - const transporter4 = createTransporter(); - await testTransporter( - transporter4, - 'Different from address', - { from: `"Test" <${SMTP_USER}>` } - ); - - console.log('\nAll tests completed!'); - - } catch (error) { - console.error('Error running tests:', error); - } -} - -// Test a specific transporter configuration -async function testTransporter(transporter, testName, options = {}) { - console.log(`Testing ${testName}...`); - - try { - // Verify connection - await new Promise((resolve, reject) => { - transporter.verify((error, success) => { - if (error) { - console.error(`Connection test failed for ${testName}:`, error); - reject(error); - } else { - console.log(`Connection successful for ${testName}`); - resolve(success); - } - }); - }); - - // Send test email - const fromAddress = options.from || `"${WEBSITE_NAME}" <${SMTP_USER}>`; - - const info = await transporter.sendMail({ - from: fromAddress, - to: ADMIN_EMAIL, - subject: `Production Email Test: ${testName}`, - text: `This is a test email from the production-email-test.cjs script using ${testName}.\n\nTime: ${new Date().toISOString()}`, - html: ` -
-

Production Email Test: ${testName}

-

This is a test email from the production-email-test.cjs script using ${testName}.

-

Time: ${new Date().toISOString()}

-

Configuration:

- -
- ` - }); - - console.log(`Email sent successfully for ${testName}!`); - console.log(`Message ID: ${info.messageId}`); - console.log(`Response: ${info.response}`); - - return info; - } catch (error) { - console.error(`Error in ${testName}:`, error); - throw error; - } -} - -// Run the tests -runTests().catch(error => { - console.error('Unhandled error:', error); - process.exit(1); -}); \ No newline at end of file diff --git a/protonmail-test.cjs b/protonmail-test.cjs deleted file mode 100644 index beb9c35..0000000 --- a/protonmail-test.cjs +++ /dev/null @@ -1,69 +0,0 @@ -// Simple ProtonMail SMTP test -const nodemailer = require('nodemailer'); -require('dotenv').config(); - -// Get SMTP settings from environment variables -const { - SMTP_HOST = 'smtp.protonmail.ch', - SMTP_PORT = '587', - SMTP_USER, - SMTP_PASS, - ADMIN_EMAIL -} = process.env; - -console.log('ProtonMail SMTP Test'); -console.log('-------------------'); -console.log(`SMTP Host: ${SMTP_HOST}`); -console.log(`SMTP Port: ${SMTP_PORT}`); -console.log(`SMTP User: ${SMTP_USER}`); -console.log(`Admin Email: ${ADMIN_EMAIL}`); - -// ProtonMail specific configuration -const transporter = nodemailer.createTransport({ - host: SMTP_HOST, - port: parseInt(SMTP_PORT, 10), - secure: false, // For ProtonMail, use false for port 587 - auth: { - user: SMTP_USER, - pass: SMTP_PASS, - }, - tls: { - // Do not fail on invalid certs - rejectUnauthorized: false, - // Specific ciphers for ProtonMail - ciphers: 'SSLv3' - }, - logger: true, - debug: true // Include SMTP traffic in the logs -}); - -// Verify connection -console.log('\nTesting connection to ProtonMail SMTP server...'); -transporter.verify(function(error, _success) { - if (error) { - console.error('Connection failed:', error); - process.exit(1); - } else { - console.log('Server is ready to take our messages'); - - // Send test email - console.log('\nSending test email...'); - transporter.sendMail({ - from: SMTP_USER, - to: ADMIN_EMAIL, - subject: 'ProtonMail SMTP Test', - text: 'This is a test email from your website contact form.', - html: '

This is a test email from your website contact form.

' - }, (err, info) => { - if (err) { - console.error('Error sending email:', err); - process.exit(1); - } else { - console.log('Message sent successfully!'); - console.log('Message ID:', info.messageId); - console.log('Response:', info.response); - process.exit(0); - } - }); - } -}); \ No newline at end of file diff --git a/protonmail-test2.cjs b/protonmail-test2.cjs deleted file mode 100644 index 026e51c..0000000 --- a/protonmail-test2.cjs +++ /dev/null @@ -1,97 +0,0 @@ -// ProtonMail SMTP test with alternative configuration -const nodemailer = require('nodemailer'); -require('dotenv').config(); - -// Get SMTP settings from environment variables -const { - SMTP_USER, - SMTP_PASS, - ADMIN_EMAIL -} = process.env; - -console.log('ProtonMail SMTP Test (Alternative Configuration)'); -console.log('----------------------------------------------'); -console.log(`SMTP User: ${SMTP_USER}`); -console.log(`Admin Email: ${ADMIN_EMAIL}`); - -// Try alternative ProtonMail configuration -// ProtonMail Bridge typically uses localhost:1025 or localhost:1143 -const transporterOptions = { - host: 'mail.protonmail.ch', - port: 443, - secure: true, - auth: { - user: SMTP_USER, - pass: SMTP_PASS, - }, - tls: { - rejectUnauthorized: false - }, - logger: true, - debug: true -}; - -console.log('\nUsing configuration:'); -console.log(`Host: ${transporterOptions.host}`); -console.log(`Port: ${transporterOptions.port}`); -console.log(`Secure: ${transporterOptions.secure}`); - -const transporter = nodemailer.createTransport(transporterOptions); - -// Verify connection -console.log('\nTesting connection to ProtonMail SMTP server...'); -transporter.verify(function(error, _success) { - if (error) { - console.error('Connection failed:', error); - console.log('\nTrying alternative port (25)...'); - - // Try port 25 - const transporter2 = nodemailer.createTransport({ - ...transporterOptions, - port: 25, - secure: false - }); - - transporter2.verify(function(error2, _success2) { - if (error2) { - console.error('Connection with port 25 also failed:', error2); - - console.log('\nImportant ProtonMail SMTP Notes:'); - console.log('1. ProtonMail requires the Bridge application for SMTP access from third-party apps'); - console.log('2. The Bridge runs locally and provides SMTP access via localhost:1025 or similar'); - console.log('3. You may need to install and configure ProtonMail Bridge on your server'); - console.log('4. Or use ProtonMail\'s API instead of SMTP for sending emails'); - - process.exit(1); - } else { - console.log('Connection successful with port 25!'); - sendTestEmail(transporter2); - } - }); - } else { - console.log('Server is ready to take our messages'); - sendTestEmail(transporter); - } -}); - -function sendTestEmail(transport) { - // Send test email - console.log('\nSending test email...'); - transport.sendMail({ - from: SMTP_USER, - to: ADMIN_EMAIL, - subject: 'ProtonMail SMTP Test (Alternative Config)', - text: 'This is a test email from your website contact form.', - html: '

This is a test email from your website contact form.

' - }, (err, info) => { - if (err) { - console.error('Error sending email:', err); - process.exit(1); - } else { - console.log('Message sent successfully!'); - console.log('Message ID:', info.messageId); - console.log('Response:', info.response); - process.exit(0); - } - }); -} \ No newline at end of file diff --git a/public/test-contact-form.html b/public/test-contact-form.html deleted file mode 100644 index a9faca2..0000000 --- a/public/test-contact-form.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Contact Form Test - - - -

Contact Form Test

- -
- Your message has been sent successfully! -
- -
- There was an error sending your message. Please try again. -
- -
- - -
- - -
- -
- - -
- -
- - -
- -
- -
- - -
- -
-

Debug Log

-
-
- - - - \ No newline at end of file diff --git a/public/test-language-persistence.html b/public/test-language-persistence.html deleted file mode 100644 index 65baa0e..0000000 --- a/public/test-language-persistence.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - Language Persistence Test - - - -

Language Persistence Test

- -
-

Current Language Status

-
-

URL Language: Checking...

-

LocalStorage Language: Checking...

-

Cookie Language: Checking...

-
-
- -
-

Test Language Selection

-

Click on a language to test the language persistence:

-
- - - - -
-
- -
-

Navigation Test

-

Use these links to test language persistence during navigation:

- -
- - - - \ No newline at end of file diff --git a/public/test-language-switching.html b/public/test-language-switching.html deleted file mode 100644 index ca017d3..0000000 --- a/public/test-language-switching.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - Language Switching Test - - - -

Language Switching Test

- -
-

Current URL Information

-
Loading...
-
- -
-

Switch Language

-

Click on a language to switch:

-
- English - Dutch - German - French -
-
- -
-

Test Hash Navigation

-

Click on a section to navigate:

-
- Services - Contact - About -
-
- -
-

Test Page Navigation

-

Navigate to different pages:

-
- Home - About Me -
-
- - - - \ No newline at end of file diff --git a/src/test-email.ts b/src/test-email.ts deleted file mode 100644 index 13aa790..0000000 --- a/src/test-email.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { testEmailConfiguration, sendAdminNotification } from '../utils/email-handler'; -import 'dotenv/config'; - -async function runEmailTest() { - console.log('Starting email configuration test...'); - - // Test the SMTP connection - const configTest = await testEmailConfiguration(); - console.log(`Configuration test result: ${configTest ? 'SUCCESS' : 'FAILED'}`); - - if (configTest) { - // Try sending a test email - console.log('Attempting to send a test email...'); - const emailResult = await sendAdminNotification( - 'Test User', - 'test@example.com', - 'This is a test message sent at ' + new Date().toISOString(), - '127.0.0.1', - 'Email Test Script' - ); - - console.log(`Test email result: ${emailResult ? 'SENT' : 'FAILED'}`); - } - - console.log('Email test completed'); -} - -runEmailTest().catch((error) => { - console.error('Error running email test:', error); - process.exit(1); -}); diff --git a/test-contact-curl.sh b/test-contact-curl.sh deleted file mode 100755 index d342dda..0000000 --- a/test-contact-curl.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# Test script for the contact form API using curl -# This script simulates a form submission to the contact form API - -API_URL="http://localhost:4321/api/contact" -# Get admin email from environment variable or use a placeholder for testing -ADMIN_EMAIL="${ADMIN_EMAIL:-admin@example.com}" - -echo "Starting contact form test with curl..." -echo "API URL: $API_URL" - -# Step 1: Get CSRF token -echo "Getting CSRF token..." -CSRF_RESPONSE=$(curl -s "$API_URL?csrf=true") -echo "CSRF Response: $CSRF_RESPONSE" - -# Extract CSRF token -CSRF_TOKEN=$(echo $CSRF_RESPONSE | grep -o '"csrfToken":"[^"]*"' | cut -d'"' -f4) -echo "CSRF Token: $CSRF_TOKEN" - -if [ -z "$CSRF_TOKEN" ]; then - echo "Failed to get CSRF token. Aborting test." - exit 1 -fi - -# Step 2: Submit the form -echo "Submitting form..." -FORM_RESPONSE=$(curl -s -X POST "$API_URL" \ - -H "Content-Type: application/x-www-form-urlencoded" \ - -H "Accept: application/json" \ - -H "User-Agent: test-contact-curl-script" \ - --data-urlencode "name=Test User" \ - --data-urlencode "email=$ADMIN_EMAIL" \ - --data-urlencode "message=This is a test message from the test-contact-curl.sh script. $(date)" \ - --data-urlencode "disclaimer=on" \ - --data-urlencode "csrf_token=$CSRF_TOKEN" \ - --data-urlencode "timestamp=$(date +%s)") - -echo "Form submission response: $FORM_RESPONSE" - -# Check if submission was successful -if echo "$FORM_RESPONSE" | grep -q '"success":true'; then - echo "Form submission successful!" -else - echo "Form submission failed." - echo "Response: $FORM_RESPONSE" - exit 1 -fi - -echo "Test completed successfully." \ No newline at end of file diff --git a/test-contact-form.cjs b/test-contact-form.cjs deleted file mode 100644 index 1a53c77..0000000 --- a/test-contact-form.cjs +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Test script for the contact form API - * This script simulates a form submission to the contact form API - */ - -const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); -const FormData = require('form-data'); -require('dotenv').config(); - -// URL of the contact form API -const API_URL = 'http://localhost:4321/api/contact'; - -// Function to get a CSRF token -async function getCsrfToken() { - try { - console.log(`Fetching CSRF token from ${API_URL}?csrf=true`); - const response = await fetch(`${API_URL}?csrf=true`); - console.log('CSRF response status:', response.status); - - if (!response.ok) { - console.error('CSRF request failed:', response.statusText); - return null; - } - - const text = await response.text(); - console.log('CSRF response text:', text); - - try { - const data = JSON.parse(text); - console.log('CSRF token data:', data); - return data.csrfToken; - } catch (parseError) { - console.error('Error parsing CSRF response:', parseError); - console.error('Response was not valid JSON:', text); - return null; - } - } catch (error) { - console.error('Error getting CSRF token:', error); - return null; - } -} - -// Function to submit the form -async function submitForm(csrfToken) { - console.log('Creating form data for submission'); - - // Create form data - const formData = new FormData(); - const testEmail = process.env.ADMIN_EMAIL || 'richard@bergsma.it'; - const testMessage = 'This is a test message from the test-contact-form.cjs script. ' + new Date().toISOString(); - - formData.append('name', 'Test User'); - formData.append('email', testEmail); - formData.append('message', testMessage); - formData.append('disclaimer', 'on'); - formData.append('csrf_token', csrfToken); - formData.append('timestamp', Date.now().toString()); - - console.log('Submitting form with data:', { - name: 'Test User', - email: testEmail, - messageLength: testMessage.length, - disclaimer: 'on', - csrfToken: csrfToken ? 'present' : 'missing', - }); - - try { - console.log(`Sending POST request to ${API_URL}`); - const response = await fetch(API_URL, { - method: 'POST', - body: formData, - headers: { - 'Accept': 'application/json', - 'User-Agent': 'test-contact-form-script' - } - }); - - console.log('Response status:', response.status); - - if (!response.ok) { - console.error('Form submission failed with status:', response.status, response.statusText); - } - - const text = await response.text(); - console.log('Response text:', text); - - try { - const result = JSON.parse(text); - console.log('Form submission result:', result); - return result; - } catch (parseError) { - console.error('Error parsing response:', parseError); - console.error('Response was not valid JSON:', text); - return { success: false, error: 'Invalid JSON response' }; - } - } catch (error) { - console.error('Error submitting form:', error); - return { success: false, error: error.message }; - } -} - -// Main function -async function main() { - console.log('Starting contact form test...'); - console.log(`API URL: ${API_URL}`); - - // Get CSRF token - console.log('Getting CSRF token...'); - const csrfToken = await getCsrfToken(); - - if (!csrfToken) { - console.error('Failed to get CSRF token. Aborting test.'); - process.exit(1); - } - - console.log('CSRF token received:', csrfToken ? 'Yes' : 'No'); - - // Submit the form - console.log('Submitting form...'); - const result = await submitForm(csrfToken); - - if (result.success) { - console.log('Form submission successful!'); - } else { - console.error('Form submission failed:', result); - } -} - -// Run the test -main().catch(error => { - console.error('Unhandled error:', error); - process.exit(1); -}); \ No newline at end of file diff --git a/test-email.ts b/test-email.ts deleted file mode 100644 index 070c57b..0000000 --- a/test-email.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { testEmailConfiguration, sendAdminNotification } from './src/utils/email-handler.js'; -import 'dotenv/config'; - -async function runEmailTest() { - console.log('Starting email configuration test...'); - - // Test the SMTP connection - const configTest = await testEmailConfiguration(); - console.log(`Configuration test result: ${configTest ? 'SUCCESS' : 'FAILED'}`); - - if (configTest) { - // Try sending a test email - console.log('Attempting to send a test email...'); - const emailResult = await sendAdminNotification( - 'Test User', - 'test@example.com', - 'This is a test message sent at ' + new Date().toISOString(), - '127.0.0.1', - 'Email Test Script' - ); - - console.log(`Test email result: ${emailResult ? 'SENT' : 'FAILED'}`); - } - - console.log('Email test completed'); -} - -runEmailTest().catch(error => { - console.error('Error running email test:', error); - process.exit(1); -}); \ No newline at end of file diff --git a/test-smtp.js b/test-smtp.js deleted file mode 100644 index 8eb9869..0000000 --- a/test-smtp.js +++ /dev/null @@ -1,87 +0,0 @@ -const nodemailer = require('nodemailer'); -require('dotenv').config(); - -// Get SMTP settings from environment variables -const { - SMTP_HOST, - SMTP_PORT, - SMTP_USER, - SMTP_PASS, - ADMIN_EMAIL, - WEBSITE_NAME -} = process.env; - -console.log('SMTP Configuration Test'); -console.log('----------------------'); -console.log(`SMTP Host: ${SMTP_HOST}`); -console.log(`SMTP Port: ${SMTP_PORT}`); -console.log(`SMTP User: ${SMTP_USER}`); -console.log(`Admin Email: ${ADMIN_EMAIL}`); -console.log(`Website Name: ${WEBSITE_NAME}`); -console.log('----------------------'); - -// Create a transporter -const transporter = nodemailer.createTransport({ - host: SMTP_HOST, - port: parseInt(SMTP_PORT, 10), - secure: parseInt(SMTP_PORT, 10) === 465, - auth: { - user: SMTP_USER, - pass: SMTP_PASS, - }, - // Required for ProtonMail - tls: { - ciphers: 'SSLv3', - rejectUnauthorized: false - } -}); - -// Test the connection -console.log('Testing SMTP connection...'); -transporter.verify((error, success) => { - if (error) { - console.error('SMTP Connection Error:', error); - console.error('Error Name:', error.name); - console.error('Error Message:', error.message); - - // Provide troubleshooting advice based on error - if (error.message.includes('ECONNREFUSED')) { - console.error('\nTroubleshooting: Connection refused'); - console.error('- Check if the SMTP server address is correct'); - console.error('- Verify the port is correct and not blocked by a firewall'); - console.error('- Ensure your internet connection is working'); - } else if (error.message.includes('Invalid login') || error.message.includes('authentication failed')) { - console.error('\nTroubleshooting: Authentication failed'); - console.error('- Verify your username and password are correct'); - console.error('- For ProtonMail, ensure you\'re using an app-specific password'); - console.error('- Check if 2FA is enabled and properly configured'); - } else if (error.message.includes('certificate')) { - console.error('\nTroubleshooting: SSL/TLS Certificate Error'); - console.error('- The server\'s SSL certificate could not be verified'); - console.error('- This might be resolved by setting rejectUnauthorized: false (already set)'); - } - } else { - console.log('SMTP Connection Successful!'); - console.log('The server is ready to accept messages'); - - // Send a test email - console.log('\nSending a test email...'); - const mailOptions = { - from: `"${WEBSITE_NAME}" <${ADMIN_EMAIL}>`, - to: ADMIN_EMAIL, - subject: 'SMTP Test Email', - text: 'This is a test email to verify SMTP configuration is working correctly.', - html: '

This is a test email to verify SMTP configuration is working correctly.

' - }; - - transporter.sendMail(mailOptions, (error, info) => { - if (error) { - console.error('Error sending test email:', error); - } else { - console.log('Test email sent successfully!'); - console.log('Message ID:', info.messageId); - console.log('Response:', info.response); - } - }); - } -}); \ No newline at end of file