Cannot connect to mailserver that does not support authentication

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 4 años
The 4.3 development version based on mailkit has an issue sending mails when the SMTP server does not have authentication enabled.
I am using Office 365 to send mails, it is configure to authenticate based on source IP address and does not accept authentication. In 4.2 this works fine but the mailkit implementation always tries to authenticate even if no username/password is configured.

To get it working I made the following change in SmtpBuilder:

                if (emailAccount.UseDefaultCredentials || !string.IsNullOrWhiteSpace(emailAccount.Username))
                {
                    client.Authenticate(emailAccount.UseDefaultCredentials ?
                            CredentialCache.DefaultNetworkCredentials :
                            new NetworkCredential(emailAccount.Username, emailAccount.Password));
                }

Lex
Hace 4 años
Thanks for this information. Here is a work item.
Hace 4 años
I am having the same issue testing 4.30, i cant connect to my exchange server but using 4.20 everthing is good. Where on 4.30 source do i need to modify to get it to work? Thank you
Hace 4 años
I am trying to get ideas here and add them to source to test.

https://github.com/jstedfast/MailKit/issues/307
Hace 4 años
I want to try the below, because i also have an issue with the ssl certificate, when SSl is ticked then i get an error about the certificate being empty on the excahange log files.

client.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => {
    if (sslPolicyErrors == SslPolicyErrors.None)
        return true;

    // if there are errors in the certificate chain, look at each error to determine the cause.
    if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) != 0) {
        if (chain != null && chain.ChainStatus != null) {
            foreach (var status in chain.ChainStatus) {
                if ((certificate.Subject == certificate.Issuer) && (status.Status == X509ChainStatusFlags.UntrustedRoot)) {
                    // self-signed certificates with an untrusted root are valid.
                    continue;
                } else if (status.Status != X509ChainStatusFlags.NoError) {
                    // if there are any other errors in the certificate chain, the certificate is invalid,
                    // so the method returns false.
                    return false;
                }
            }
        }

        // When processing reaches this line, the only errors in the certificate chain are
        // untrusted root errors for self-signed certificates. These certificates are valid
        // for default Exchange server installations, so return true.
        return true;
    }

    return false;
};
Hace 4 años
We fixed it! Thanks a lot. See this commit for more details
Hace 2 años
To use this, what all has to be recompiled?
Does anyone know offhand which compiled DDL file this will change?
Or does the whole project have to be recompiled?
Hace 2 años
Make the changes
Rebuild the Solution
Publish the Solution
- The only file that should change is Nop.Services.dll
Stop webserver
Copy this file to production
Restart webserver
Hace 2 años
Thanks!
Hace 2 años
I changed the code per the above link.
I then deployed all changed files.

I am still getting the error -
The SMTP server does not support authentication.

I have the user and password empty.
Any ideas?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.