-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
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: testemail@gmail.com
Validation Result: {
verifiedEmail: 'testemail@gmail.com',
valid: false,
message: 'Connection timeout'}
Metadata
Metadata
Assignees
Labels
No labels