Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created July 13, 2017 05:32
Show Gist options
  • Save jcefoli/5e10e601426d9856bf388a7aeb07a572 to your computer and use it in GitHub Desktop.
Save jcefoli/5e10e601426d9856bf388a7aeb07a572 to your computer and use it in GitHub Desktop.
Send Email via Powershell (Simple Example)
#Configurable Variables
$EmailFrom = "[email protected]"
$EmailTo = "[email protected],[email protected]"
$Subject = "Email Subject Goes Here"
$Body = "The body of the email goes here."
$SMTPServer = "SMTP-SRV-01"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
<#
#Uncomment to use Gmail's SMTP server. Might need to change the port aboce
SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("[email protected]", "YourGmailPassword");
#>
#Actually send the email
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment