Share this page : facebooktwitterlinkedinmailfacebooktwitterlinkedinmail
send email from powershell

 

$EmailTo = “receiver_email
$EmailFrom = “sender_email
$Subject = “Test
$Body = “Test Body
$SMTPServer = “smtp_server
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“email account“, “email_password“);
$SMTPClient.Send($SMTPMessage)

 

Change the blue part into your email parameters.