小编Jan*_*anF的帖子

PowerShell 上的 Send-MailMessage 不起作用

我有一个大问题。对于学校俱乐部,我必须编写一个自动发送电子邮件的脚本。我决定为此使用 PowerShell。

我的代码:

Send-MailMessage –To "email@outlook.com" –Subject "Test E-Mail" –Body "FIRST EMAIL WITH POWERSHELL" –SmtpServer "smtp.gmail.com" –From "email@gmail.com"
Run Code Online (Sandbox Code Playgroud)

我的错误代码:

Send-MailMessage:SMTP 服务器需要安全连接或客户端尚未通过身份验证。服务器响应为:5.7.0 必须首先发出 STARTTLS 命令。o3sm51888528wrs.30 - gsmtp In line: 1 character: 1 + Send-MailMessage -To "email@outlook.com" 主题 "Test E-Mail" -Bod ... + ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidOperation: (System.Net .Mail.SmtpClient: SmtpClient) [Send-MailMessage], SmtpException +fullyQualifiedErrorId: SmtpException, Microsoft.PowerShell.Commands.SendMailMessage

如果我写

–SmtpServer "gsmtp.gmail.com"
Run Code Online (Sandbox Code Playgroud)

错误代码是:

Send-MailMessage : 无法建立到远程服务器的连接。In line:1 character:1 + Send-MailMessage -To "email@outlook.com"; - 主题“测试电子邮件”;- 博德。. . + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) …

email powershell

2
推荐指数
1
解决办法
4262
查看次数

标签 统计

email ×1

powershell ×1