We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Checking the validity of Email server data

Hello, unfortunately, among your documentation, I could not find a way to verify the correctness of the entered port of the email server, I would like to know if it is possible for you to check the entered server data and, if an error occurs, find out what is entered not correctly: port, address, security options, password or login

@Far1d

Could you please share some more detail about your requirement along with sample input and expected output? We will then provide you more information about it.

@tahir.manzoor
This is necessary because we work with different email servers and each server has different ports and security settings

I need that after creating any SMTP, IMAP, POP3 client, there is a method for example TestConnection() that will return true in case of connection, if the data is entered incorrectly, suppose the port is entered incorrectly, an IncorrectPortException() exception will be thrown, and also in the case of the server address, login, password, protocol, etc.

At the moment I use this code, but the ValidateCredentials() method checks only the login and password, but we have cases when the user enters incorrect server data, too, in this case ValidateCredentials() does not return anything until a TimeoutException is thrown

public boolean checkCredentials(EmailData emailData) {
EmailClient client = null;
switch (emailData.getEmailProtocolTypeInc()) {
case 1:
client = new SmtpClient(emailData.getEmailHost(),
emailData.getEmailUsername(), emailData.getEmailPassword());
break;
case 2:
client = new ImapClient(emailData.getEmailHost(),
emailData.getEmailUsername(), emailData.getEmailPassword());
break;
case 3:
client = new Pop3Client(emailData.getEmailHost(),
emailData.getEmailUsername(), emailData.getEmailPassword());
break;
}
client.setSecurityOptions(SecurityOptions.Auto);
client.setPort(client.getDefaultPort());
client.setTimeout(5000);

    return client.validateCredentials();
}

@Far1d

We have logged a ticket for your requirement in our issue tracking system as EMAILJAVA-35128. We will inform you once there is an update available on it.

@Far1d

It is to inform you that we have closed the ticket EMAILJAVA-35128 with Won’t Fix resolution.

We can check the connection for an incorrect login or password, in this case the server gives an appropriate error.

In case of a wrong port or hostname, we cannot establish a connection to determine the error, we cannot predict the settings of the remote server.

We can validate settings for public mail services, but in this case we will need to maintain and synchronize settings for many public mail services.

We can also determine settings by domain name in case of Exchange Server(autodiscover), but this will also not work if the domain name is incorrect or if autodiscover settings is not defined on the server.