title: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The specified data could not be decrypted
body: <p>Once I am using mandrill smtp server instead of <em>smtp.gmail.com</em>, system fails(randomly) to send some email at first attempt and success in second attempt. 
  I have some similar post but non of those solve my issue. </p>
  
  <p>Here is the exception track trace (copied from database log, excuse me on bad format of the trace)</p>
  
  <blockquote>
    <p><em>System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. --->
    System.ComponentModel.Win32Exception: The specified data could not be
    decrypted --- End of inner exception stack trace --- at
    System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken
    message, AsyncProtocolRequest asyncRequest, Exception exception) at
    System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken
    message, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32
    readBytes, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer,
    AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken
    message, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32
    readBytes, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer,
    AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken
    message, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32
    readBytes, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer,
    AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken
    message, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32
    count, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,
    Byte[] buffer, AsyncProtocolRequest asyncRequest) at
    System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult
    lazyResult) at System.Net.TlsStream.CallProcessAuthentication(Object
    state) at
    System.Threading.ExecutionContext.RunInternal(ExecutionContext
    executionContext, ContextCallback callback, Object state, Boolean
    preserveSyncCtx) at
    System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state, Boolean
    preserveSyncCtx) at
    System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state) at
    System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at
    System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at
    System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
    at System.Net.Mail.SmtpConnection.Flush() at
    System.Net.Mail.ReadLinesCommand.Send(SmtpConnection conn) at
    System.Net.Mail.EHelloCommand.Send(SmtpConnection conn, String domain)
    at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint
    servicePoint) at
    System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
    at System.Net.Mail.SmtpClient.GetConnection() at
    System.Net.Mail.SmtpClient.Send(MailMessage message) at
    Nop.Services.Messages.EmailSender.SendEmail(EmailAccount emailAccount,
    String subject, String body, MailAddress from, MailAddress to,
    IEnumerable<code>1 bcc, IEnumerable</code>1 cc, String attachmentFilePath, String
    attachmentFileName) at
    Nop.Services.Messages.EmailSender.SendEmail(EmailAccount emailAccount,
    String subject, String body, String fromAddress, String fromName,
    String toAddress, String toName, IEnumerable<code>1 bcc, IEnumerable</code>1 cc,
    String attachmentFilePath, String attachmentFileName) at
    Nop.Services.Messages.QueuedMessagesSendTask.Execute()</em></p>
  </blockquote>
  
  <p>Here is the code block that use to send email</p>
  
  <pre><code> using (var smtpClient = new SmtpClient())
    {
  
              smtpClient.UseDefaultCredentials = emailAccount.UseDefaultCredentials;
              smtpClient.Host = emailAccount.Host;
              smtpClient.Port = emailAccount.Port;
              smtpClient.EnableSsl = emailAccount.EnableSsl;
              if (emailAccount.UseDefaultCredentials)
                  smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
              else
                  smtpClient.Credentials = new NetworkCredential(emailAccount.Username, emailAccount.Password);
              smtpClient.Send(message);
     }
  </code></pre>