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
| $From = "your-gmail-address@gmail.com" | |
| $To = "the-destination-user@domain.com" | |
| $Subject = "Email subject goes here" | |
| $Body = "Email body goes here" | |
| # The password is an app-specific password if you have 2-factor-auth enabled | |
| $Password = "app-specific-password-here" | ConvertTo-SecureString -AsPlainText -Force | |
| $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $From, $Password | |
| Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer "smtp.gmail.com" -port 587 -UseSsl -Credential $Credential |