我收到错误:
Send-MailMessage:SMTP服务器需要安全连接,或者客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息 在C:\ documents \ yes.ps1:22 char:1
+ Send-MailMessage @EmailSplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation:(System.Net.Mail.SmtpClient:SmtpClient)[Send-MailMessage],SmtpExcept 离子
+ FullyQualifiedErrorId:SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
$MyEmail = "****@gmail.com"
$SMTP= "smtp.gmail.com"
$To = "****@gmail.com"
$Subject = "Attachments"
$Body = "Here's the attachment"
$Creds = (Get-Credential -Credential "$MyEmail")
$env:localappdata
Start-Sleep 2
$Attachments = get-childitem "$env:******" | select-object -ExpandProperty FullName
$EmailSplat = @{To = $to
From = $MyEmail
Attachments = $Attachments
Subject = $Subject
Body = $Body
SmtpServer = $SMTP
Credential = $Creds
UseSsl = $True
Port = 587
DeliveryNotificationOption = 'never'
}
Send-MailMessage @EmailSplat
答案 0 :(得分:1)
没有此步骤的步骤是: 应用密码
允许安全性较低的应用之后,我仍然面临着同样的问题,因为Google最近更新了其身份验证机制。这是步骤
对于OP,“我的图像”显示所需的内容。
After Enabling Two Factor Authentication this is what should be there
答案 1 :(得分:0)
您需要在Google帐户中启用允许安全性较低的应用,因为Google可能阻止某些不使用现代安全标准的应用(或设备)尝试登录。
登录Google帐户,然后转到:
https://www.google.com/settings/security/lesssecureapps
启用允许安全性较低的应用选项。