我使用下面的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
所以有人能建议我如何解决这个问题吗。
发布于 2020-12-23 02:28:50
它看起来像是一个网络连接问题,您可以检查以下内容:
有关更多信息,建议使用使用SendGrid提供的API键发送电子邮件,而不是通过脚本发送密码。
发布于 2022-05-29 11:32:27
我通过将安全协议更改为TLS 1.2来修正此错误(在非Azure环境中):
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
详细信息:Powershell将安全协议设置为Tls 1.2
相关:连接闭
https://stackoverflow.com/questions/65411405
复制相似问题