Created
July 13, 2017 05:32
-
-
Save jcefoli/5e10e601426d9856bf388a7aeb07a572 to your computer and use it in GitHub Desktop.
Send Email via Powershell (Simple Example)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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