【发布时间】:2020-12-21 13:43:14
【问题描述】:
我正在尝试使用以下Powershell 任务在Azure Devops 的管道上发送一些电子邮件:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$username = "$(emailUsername)"
$password = ConvertTo-SecureString -String "$(emailPassword)" -AsPlainText -Force
$credentials = [PSCredential]::New($username, $password)
$sendMailParams = @{
SMTPServer = 'smtp.office365.com'
Port = 587
UseSsl = $false
Credential = $credentials
From = $username
To = '${{ parameters.recipientsAddresses }}'
Subject = '${{ parameters.mailSubject }}'
Body = '${{ parameters.mailBody }}'
}
$encoding = [System.Text.Encoding]::UTF8
Send-MailMessage @sendMailParams -Encoding $encoding
PowerShell 脚本可以在我的机器上本地运行,但是当我尝试在我的管道上运行它时它会失败并显示以下消息:
Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server
response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [<MAIL_SERVER>.outlook.com]
我在这里错过了什么?
【问题讨论】:
-
你有MS代理还是自托管代理?
-
MS代理,目前在
ubuntu-latest上运行 -
所以我猜你需要打开端口或在你的 SMTP 中访问代理 ip
标签: azure powershell azure-devops