08 October 2013

Send mail message from powershell


Send-MailMessage -From "user@domain.com" -To "user@domain.com" -Subject "subject" -Body "Message" -SmtpServer servername.local


or by using splatting:


$body = "body message"

$email = @{
From = "user@domain.com"
To = "user@domain.com"
Subject = "subject"
SMTPServer = "servername.local"
Body = $body
}

Send-MailMessage @email

1 comment:

  1. Noroc
    To send to multiple recipients use this:
    -To User2 ", "User3 "

    ReplyDelete