微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Send-MailMessage:无法从传输连接读取数据:net_io_connectionclosed

如何解决Send-MailMessage:无法从传输连接读取数据:net_io_connectionclosed

我使用以下 PowerShell 脚本通过 Azure SendGrid 帐户详细信息发送电子邮件。执行脚本时,我收到错误 Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed

PoweShell 脚本:

$Username ="xxxxx@azure.com"
$Password = ConvertTo-securestring "xxxx" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $Username,$Password
$SMTPServer = "smtp.sendgrid.net"
$EmailFrom = "from@mail.com"
$EmailTo = "to@mail.com"
$Subject = "SendGrid test"
$Body = "SendGrid testing successful"

Send-MailMessage -smtpServer $SMTPServer -Credential $credential -Usessl -Port 587 -from $EmailFrom -to $EmailTo -subject $Subject -Body $Body

那么,谁能建议我如何解决这个问题。

解决方法

看起来是网络连接问题,您可以检查以下内容:

  • 如果您可以访问服务器上的 SMTP 端口 (587)。您可以使用 Telnet 来测试 SMTP 通信。请参阅this
  • 如果您输入了正确的参数,例如凭据。

有关详细信息,建议使用 use API Keys provided by SendGrid to send emails 而不是通过脚本发送密码。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。