【问题标题】:Not able to sent mail through gmail SMTP in Azure server无法通过 Azure 服务器中的 gmail SMTP 发送邮件
【发布时间】:2017-05-03 11:47:40
【问题描述】:

我的代码在其他域和本地工作。但是当我尝试通过 Azure 服务器发送邮件时它不起作用。 我在堆栈溢出中看起来几乎所有帮助链接,但仍然无法正常工作。

我在用这个东西

smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("xyzanjyr@gmail.com", "***********");
smtp.EnableSsl = true;

我遇到了这个异常

System.Net.Mail.SmtpException: Failure sending mail. ---> 
System.ComponentModel.Win32Exception: The client and server cannot communicate, because they do not possess a common algorithm\r\n   at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)\r\n   at System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage, SecureCredential& secureCredential)\r\n   at System.Net.Security.SecureChannel.AcquireClientCredentials(Byte[]& thumbPrint)\r\n   at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)\r\n   at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)\r\n   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)\r\n   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)\r\n   at System.Net.Mail.SmtpConnection.Flush()\r\n   at System.Net.Mail.ReadLinesCommand.Send(SmtpConnection conn)\r\n   at System.Net.Mail.EHelloCommand.Send(SmtpConnection conn, String domain)\r\n   at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)\r\n   at System.Net.Mail.SmtpClient.GetConnection()\r\n   at System.Net.Mail.SmtpClient.Send(MailMessage message)

【问题讨论】:

  • 请复制粘贴异常
  • 我有更新问题请检查

标签: c# email azure smtp gmail


【解决方案1】:

我只是在发送邮件之前使用此代码,它工作正常。

System.Net.ServicePointManager.SecurityProtocol = 
    System.Net.SecurityProtocolType.Ssl3 
    | System.Net.SecurityProtocolType.Tls12 
    | SecurityProtocolType.Tls11 
    | SecurityProtocolType.Tls;

【讨论】:

    猜你喜欢
    • 2011-10-21
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 2014-01-17
    • 2011-03-17
    • 2013-03-13
    • 2018-06-30
    • 2020-02-21
    相关资源
    最近更新 更多