如何使用 PowerShell v3 从雅虎 SMTP 服务器发送电子邮件?需要身份验证。
Send-MailMessage
有一个-Credential
接受pscredential
对象的参数。我会使用哈希表来存储和分配连接参数:
$MailArgs = @{
From = 'mindaugas@yahoo.com'
To = 'someone@domain.com'
Subject = 'A subject line'
Body = 'Mail message content goes here!'
SmtpServer = 'smtp.mail.yahoo.com'
Port = 587
UseSsl = $true
Credential = New-Object pscredential 'mindaugas@yahoo.com',$('P@ssW0rd!' |ConvertTo-SecureString -AsPlainText -Force)
}
Send-MailMessage @MailArgs
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3252 次 |
最近记录: |