【问题标题】:Azure Automation SMTP remote name could not be resolved无法解析 Azure 自动化 SMTP 远程名称
【发布时间】:2021-07-01 10:10:50
【问题描述】:

我有一个 powershell 脚本,它将获取我的所有 azure 应用注册信息并通过电子邮件发送信息。我的笔记本电脑上有 powershell,但无法在 Azure 自动化中发送电子邮件。

这是我在 Azure 自动化中遇到的错误。我替换了我的 smtp 服务器名称。有一个实际的服务器不是那个值。我所有的变量都被填充了。同样,这在我的笔记本电脑上使用了与自动化中完全相同的脚本。

无法解析远程名称:'smtpserver'

这是它的sn-p代码

#Send Email
    $Style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
    $Style += "TABLE{border: 1px solid black; border-collapse: collapse;}"
    $Style += "TH{border: 1px solid black; background: #D8D8D8; padding: 5px; }"
    $Style += "TD{border: 1px solid black; padding: 5px; }"
    $Style += "</style>"

    $Html = ''
    $Html += "<div>These application security items are expiring in $($ExpiresInDays) days</div>"
    $Html += "<br></br>"
    $Html += $ExpiringTable | ConvertTo-Html -Head $Style
    $html += "<br></br>"
    $Html += "For troubleshooting this email, the automation for this can be found at this location: "
    $Html += "<a href="+ $($AutomationLink) +">Azure Portal: Expiring Security Items</a>"

    Send-MailMessage -SmtpServer $SmtpServer -From $EmailFrom -To $EmailTo -Subject $Subject -Body $Html -BodyAsHtml -Priority $Priority -ErrorAction Stop

【问题讨论】:

    标签: azure powershell automation azure-automation smtp-server


    【解决方案1】:

    从 Azure 自动化 Runbook 发送电子邮件的推荐方法是使用 SendGrid。更多信息请参考thisAzure 文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 2016-05-31
      • 2013-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多