With method EmailValidator.Validate, all mails is valid

Hello , i have a problem !

With method EmailValidator.Validate, all mails is valid…
Help me please !

bool MyEmail = false;
EmailValidator ev = new EmailValidator();
ValidationResult resp;
ev.Validate(“asdfhj435kjhgsd@GMAIL.COM”, out resp);

    if (resp.ReturnCode ==  ValidationResponseCode.ValidationSuccess)
    {
        MyEmail = true;
    }

Screeshoot

@PABLOOPORTUS

It seems you are experiencing an issue where the EmailValidator.Validate method is returning a success response for all email addresses, regardless of their validity. This can happen if the validation is only checking the syntax of the email address without performing more comprehensive checks.

To ensure that the email validation is effective, consider implementing additional validation techniques beyond just syntax checking. Here are some steps you can take:

  1. Syntax Verification: This is the basic check to ensure the email format is correct. However, it does not guarantee that the email address is valid.

  2. Domain Validation: Check if the domain of the email address exists. This can be done by performing a DNS lookup to verify that the domain has valid MX (Mail Exchange) records.

  3. SMTP Verification: For a more robust validation, establish an SMTP connection to the mail server associated with the email address. This will help confirm whether the email address is actually reachable.

Here is a sample code snippet that demonstrates how to implement these validation techniques using the EmailValidator class:

using Aspose.Email.Tools.Verifications;

public class EmailValidationExample
{
    public static void ValidateEmail(string email)
    {
        EmailValidator ev = new EmailValidator();
        ValidationResult result;

        ev.Validate(email, out result);

        if (result.ReturnCode == ValidationResponseCode.ValidationSuccess)
        {
            Console.WriteLine("The email address is valid.");
        }
        else
        {
            Console.WriteLine("The email address is invalid. Return code: " + result.ReturnCode);
        }
    }
}

Make sure to check the documentation for more details on how to implement domain and SMTP validation, as these methods will significantly improve the accuracy of your email validation process.

If you continue to face issues, please provide more details about the specific email addresses you are testing, and any additional code you are using for validation.

Sources:
[1]: Email Validation Techniques in C# Code - Aspose
[2]: Programming Email Verification - Aspose Documentation

Ok.
Estoy utilizando el ejemplo

pero Aspose.Email.Mail NO EXISTE

// Domain validation
var address = new Aspose.Email.Mail.MailAddress(email);
bool isSyntaxValid = address.IsValidAddress;
if (!isSyntaxValid) return false;

screeshoot ERROR.
por favor su ayuda.

Hello @PABLOOPORTUS,

Welcome to our support forum!
Aspose.Email.Tools.Verifications namespace is obsolete. Here’s an updated example to validate an email address using Aspose.Email for .NET:

using Aspose.Email.Clients;
using Aspose.Email.Clients.Smtp;
using Aspose.Email.Tools.Verifications;

bool ValidateEmail(string email)
{
    // Syntax and Domain validation
    var ev = new EmailValidator();
    ValidationResult result;
    ev.Validate(email, out result);
    
    if (result.ReturnCode == ValidationResponseCode.ValidationSuccess)
    {
        Console.WriteLine("The email address is valid.");
    }
    else
    {
        Console.WriteLine("The email address is invalid: {0}", result.Message);
    }

    // SMTP connection testing
    using (var client = new SmtpClient("smtp.server.com", port, email, "yourpassword"))
    {
        client.SecurityOptions = SecurityOptions.SSLAuto;
        
        try
        {
            client.Noop(); // Test SMTP connection
            Console.WriteLine("SMTP Connection Successful!");
        }
        catch (Exception ex)
        {
            Console.WriteLine("SMTP Connection Failed: " + ex.Message);
        }
    }

    return result.ReturnCode == ValidationResponseCode.ValidationSuccess;
}
  • EmailValidator: This class handles email syntax and domain validation.
  • SmtpClient: Used to check SMTP server connection after email validation.

This code ensures that both the email address format is valid and the SMTP connection to the email server works.

Hello Margarita…

in the code

using (var client = new SmtpClient(“smtp.server.com”, port, email, “yourpassword”))

Variables is:

My Port?
email Destiny or My email?
My Password?

Yo necesito validar un email de destino, no el email de origen.

Saludos y muchas gracias.

Hello @PABLOOPORTUS,

Let me clarify the parameters:

  • the port number of your SMTP server (e.g., 587 for TLS or 465 for SSL).
  • your email (the email you’re using to authenticate with the SMTP server).
  • your password for the SMTP server (associated with the email you’re using to authenticate).

However, if your goal is to validate the destination email, not the sender’s email (your email), you don’t need to focus on SMTP authentication for this. To validate the destination email, you should use the EmailValidator class to check the syntax and domain, as previously shown. SMTP can be used to send a test message.

Thank you.

Exacto, pero yo necesito poder validar si ese correo de destino Existe realmente.
Se puede lograr eso?

@PABLOOPORTUS ,

The most reliable way to verify if an email address exists and can receive messages is by sending a test email to the address in question.

If the message is delivered without errors, this confirms that the mailbox exists and is functioning.

If the mailbox does not exist or cannot receive messages, sending a test email will result in a delivery failure report.

However, this method has some drawbacks:

  • The recipient may perceive the test email as unwanted, especially if it is sent without prior notice.
  • Sending the email takes time, and delays in receiving a response from the server are possible.

Some email verification services use methods like partial simulation (without actually sending the email) to check if the mailbox exists, but these methods are not always reliable because many email servers are protected against such checks.

Thus, fully confirming the existence of a specific mailbox on a server cannot be guaranteed 100%, as many email servers may block verification requests.