PowerShell使用Hotmail账号发送邮件


在低版本的PowerShell上发送邮件可以借助.NET的system.net.mail.smtpclient类。在高版本的PowerShell中可以借助现成的命令:Send-MailMessage

我在尝试使用Hotmail时,遇到了一个错误:

Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a
STARTTLS command first

后来发现是没有指定端口号,应当使用:587端口号。

Send-MailMessage -Body 'test' -SmtpServer smtp.live.com -From appana@outlook.com -To 'admin@pstips.net' -Subject 'test' -UseSsl -Credential i@outlook.com -Port 587

常规错误排查:

  1. 邮箱是否开启SMTP服务
  2. 账号和密码是否输入正确
  3. 端口号是否正确

 

本文链接: https://www.pstips.net/send-mail-via-hotmail.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

关于 Mooser Lee

我是一个Powershell的爱好者,创建了PowerShell中文博客,热衷于Powershell技术的搜集和分享。本站部分内容来源于互联网,不足之处敬请谅解,并欢迎您批评指正。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注