System.Net.Mail.SmtpException套接字以其访问权限禁止的方式

问题描述

我正在尝试使用SmtpClient在具有内部(非天蓝色)电子邮件服务器的天蓝色Web服务中发送电子邮件,以发送电子邮件。我们使用混合连接进入内部网络。

 var client = new SmtpClient()
            {
                Port = model.Port,DeliveryMethod = SmtpDeliveryMethod.Network,UseDefaultCredentials = false,Host = model.Host,EnableSsl = true,Credentials = new NetworkCredential(model.UserName,model.Password)
            };
            await client.SendMailAsync(mail);

在发送电子邮件时遇到异常。

System.Net.Mail.SmtpException: Failure sending mail.
 ---> System.Net.Internals.socketExceptionFactory+ExtendedSocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions. [::ffff:xxxx.xx.xxx.xxx]:xx
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw(Exception source)
   at System.Net.sockets.socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.sockets.socket.DoMultipleAddressConnectCallback(Object result,MultipleAddressConnectAsyncResult context)
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw(Exception source)
   at System.Net.sockets.socket.DoMultipleAddressConnectCallback(Object result,MultipleAddressConnectAsyncResult context)
   at System.Net.sockets.socket.DoDnsCallback(IAsyncResult result,MultipleAddressConnectAsyncResult context)
   at System.Net.sockets.socket.DnsCallback(IAsyncResult result)
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw(Exception source)
   at System.Net.sockets.socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
   at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.InitializeConnectionCallback(IAsyncResult result)
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw(Exception source)
   at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.End(IAsyncResult result)
   at System.Net.Mail.SmtpTransport.EndGetConnection(IAsyncResult result)
   at System.Net.Mail.SmtpClient.ConnectCallback(IAsyncResult result)
   --- End of inner exception stack trace ---
   at Monash.Identity.DomainLogic.Commands.Handlers.Account.GenerateBackupCodesEmailHandler.ExecuteAsync(GenerateBackupCodesEmailCommand command) in D:\a\1\s\src\Monash.Identity.DomainLogic\Commands\Handlers\Account\GenerateBackupCodesEmailHandler.cs:line 36
   at Monash.Identity.DomainLogic.Commands.CommandHandlerBase`2.HandleAsync(TCommand command) in D:\a\1\s\src\Monash.Identity.DomainLogic\Commands\CommandHandlerBase.cs:line 28

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)