如何使用 PowerShell 从 yahoo SMTP 服务器发送电子邮件? [英] How to send an email from yahoo SMTP server with PowerShell?

查看:31
本文介绍了如何使用 PowerShell 从 yahoo SMTP 服务器发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 PowerShell v3 从 yahoo SMTP 服务器发送电子邮件?需要身份验证.

How to send an email from yahoo SMTP server with PowerShell v3? Authentication is required.

推荐答案

Send-MailMessage 有一个 -Credential 参数,该参数采用 pscredential 对象.我会使用哈希表来存储和分解连接参数:

Send-MailMessage has a -Credential parameter that takes a pscredential object. I would use a hashtable to store and splat the connection arguments:

$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

这篇关于如何使用 PowerShell 从 yahoo SMTP 服务器发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆