手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >PowerShell小技巧之使用Hotmail账号发送邮件
PowerShell小技巧之使用Hotmail账号发送邮件
摘要:在低版本的PowerShell上发送邮件可以借助.NET的system.net.mail.smtpclient类。在高版本的PowerShe...

在低版本的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

常规错误排查:

邮箱是否开启SMTP服务

账号和密码是否输入正确

端口号是否正确

【PowerShell小技巧之使用Hotmail账号发送邮件】相关文章:

PowerShell函数中使用$PSBoundParameters获取输入参数列表实例

PowerShell中正则表达式使用例子

PowerShell使用Clear-Content命令删除、清空文件内容的例子

PowerShell小技巧之配置机器的静态IP

Powershell小技巧之使用Get-ChildItem得到指定扩展名文件

PowerShell脚本trap语句捕获异常写法实例

PowerShell中使用正则表达式匹配字符串实例

PowerShell中使用Filter来创建管道输入函数

PowerShell中使用正则表达式筛选数组实例

PowerShell小技巧之同时使用可选强制参数

精品推荐
分类导航