SmtpClient with Gmail

后端 未结 6 741
忘了有多久
忘了有多久 2020-11-29 03:47

I\'m developing a mail client for a school project. I have managed to send e-mails using the SmtpClient in C#. This works perfectly with any server but it doesn

6条回答
  •  感动是毒
    2020-11-29 04:34

    I started getting this with GMail in May 2013 after working for 6 momths. The Mono project's Using Trusted Roots Respectfully document provided guidance on work around. I chose option #1:

    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
    

    It is too disruptive to have e-mail for my service stop working without warning.

    Update Aug 26 2016: user Chico suggested the following complete implementation of the ServerCertificateValidationCallback callback. I have not tested.

    ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;
    
    bool MyRemoteCertificateValidationCallback(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
        bool isOk = true;
        // If there are errors in the certificate chain, look at each error to determine the cause.
        if (sslPolicyErrors != SslPolicyErrors.None) {
            for (int i=0; i

提交回复
热议问题