Created
January 8, 2017 17:59
-
-
Save kagarlickij/2ca9d0cc59dd3c4e2caaf05ca68f3726 to your computer and use it in GitHub Desktop.
This script will send email via PowerShell
This file contains 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
$From = "dmitriy@kagarlickij.com" | |
$To = "noreply@kagarlickij.com" | |
$Subject = "Test email from $hostname on $date" | |
$body = "Running on $hostname $date" | |
$Body += "<br>" | |
$Body += "<b><font color=green>Test</b></font> <br>" | |
$SMTPServer = "smtp.gmail.com" | |
$SMTPPort = "587" | |
$mailPass = Get-Content C:\Users\vagrant\MailboxSecurePass.txt | ConvertTo-SecureString | |
$mailCred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $From,$mailPass | |
Send-MailMessage -From $From -to $To -Subject $Subject ` | |
-Body $Body -BodyAsHtml -SmtpServer $SMTPServer -port $SMTPPort -UseSsl ` | |
-Credential $mailCred |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment