【问题标题】:Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosedSend-MailMessage:无法从传输连接读取数据:net_io_connectionclosed
【发布时间】:2020-12-22 15:28:53
【问题描述】:

我使用以下 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

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

【问题讨论】:

    标签: azure smtp sendgrid azure-powershell


    【解决方案1】:

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

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

    如需了解更多信息,建议发送至use API Keys provided by SendGrid to send emails,而不是通过脚本发送密码。

    【讨论】:

    • 我正在尝试在mac os Test-NetConnection 上运行此命令以了解smtp.sendgrid.net 连接的信息。但我收到错误Not able find the command Test-NetConnection
    • 如何在mac os上测试smtp服务器的连通性而不是使用Telnet?
    • 在终端尝试nc -vz (your router's IP address) (port)。更多详情here
    • 是否有其他方法可以发送包含 Azure 资源最近部署详细信息的电子邮件?
    • 你试过我分享的link中的方法了吗?
    猜你喜欢
    • 2016-02-21
    • 2013-12-12
    • 2013-07-04
    • 2022-08-19
    • 2015-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多