https://github.com/gcclinux/powershellmail
Example how to send email using PowerShell
https://github.com/gcclinux/powershellmail
Last synced: 12 months ago
JSON representation
Example how to send email using PowerShell
- Host: GitHub
- URL: https://github.com/gcclinux/powershellmail
- Owner: gcclinux
- Created: 2022-05-27T14:01:18.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-27T14:10:28.000Z (almost 4 years ago)
- Last Synced: 2025-01-22T23:44:20.616Z (about 1 year ago)
- Language: PowerShell
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PowerShellMail
Example how to send email using PowerShell
# Update variable first.
$password = "password_here"
$username = "user_name"
$FROM = 'sender@gmail.com'
$TO = 'receiver@gmail.com'
$SUBJECT = 'Subject Test in PowerShell'
$MESSAGE = 'This is the entire message content that will be sent via powershell'
# executing script with above settings.
$secpasswd = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($username, $secpasswd)
Send-MailMessage -SmtpServer smtp.gmail.com -Credential $cred -UseSsl -From $FROM -To $TO -Subject $SUBJECT -Body $MESSAGE