Powershell Script to Send Email
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 = '[email protected]'
To = '[email protected]'
Subject = 'A subject line'
Body = 'Mail message content goes here!'
SmtpServer = 'smtp.mail.yahoo.com'
Port = 587
UseSsl = $true
Credential = New-Object pscredential '[email protected]',$('P@ssW0rd!' |ConvertTo-SecureString -AsPlainText -Force)
}
Send-MailMessage @MailArgs
source: http://stackoverflow.com/questions/36342884/how-to-send-an-email-from-yahoo-smtp-server-with-powershell/36343788#36343788