Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP TImeout issue #3

Open
suryanshsingh2001 opened this issue Jul 29, 2024 · 0 comments
Open

SMTP TImeout issue #3

suryanshsingh2001 opened this issue Jul 29, 2024 · 0 comments

Comments

@suryanshsingh2001
Copy link

suryanshsingh2001 commented Jul 29, 2024

I keep getting this message on every email.
For reference, I used a express node app

import express from 'express';
import { PingEmail } from 'ping-email';


// Create an Express application
const app = express();
const port = 3000;

// Configure the PingEmail instance
const pingEmail = new PingEmail({
    port: 267, // SMTP port
    timeout: 15000, // Time in milliseconds to wait for a response from the SMTP server
    attempts: 5, // Number of attempts to verify the email address
});

// Middleware to parse JSON request bodies
app.use(express.json());

// Endpoint to validate an email address
app.post('/validate-email', async (req, res) => {
    const { email } = req.body;
    
    if (!email) {
        return res.status(400).json({ error: 'Email is required' });
    }

    try {
        console.log("Validating Email:", email);

        const { email: verifiedEmail, valid, message } = await pingEmail.ping(email);

        console.log("Validation Result:", { verifiedEmail, valid, message });

        const result = {
            email: verifiedEmail,
            valid: valid,
            reason: message
        };

        res.json(result);
    } catch (error) {
        console.error('Error during email validation:', error);
        res.status(500).json({ error: 'Internal Server Error' });
    }
});

// Start the server
app.listen(port, () => {
    console.log(`Email validation service is running on port ${port}`);
});

Here is the response I get on running npm start

Validating Email: [email protected]
Validation Result: {
  verifiedEmail: '[email protected]',
  valid: false,
  message: 'Connection timeout'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant