Feb 20, 2011

The remote certificate is invalid according to the validation procedure

When you get this error while trying to send email using gmail's account id and your own custom code, just paste below line before you call .Send method of the smtp client like this:

ServicePointManager.ServerCertificateValidationCallback =
                    delegate(object s,
                                X509Certificate certificate,
                                X509Chain chain,
                                SslPolicyErrors sslPolicyErrors) { return true; };

// write smtp client's .send here

Once you do this,  you will see the error disappears!

1 comment: