Created
January 14, 2014 07:09
-
-
Save ThomasArdal/8414347 to your computer and use it in GitHub Desktop.
Script to send a secure mail from PowerShell.
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
$subject = $args[0] | |
$message = $args[1] | |
$from = $args[2] | |
$to = $args[3] | |
$smtpserver = "<smtp server>" | |
$smtpport = 465 | |
$username = "<smtp username>" | |
$password = "<smtp port>" | |
$credentials = New-Object System.Net.NetworkCredential($username, $password) | |
$smtp = New-Object Net.Mail.SmtpClient($smtpserver, $smtpport) | |
$smtp.EnableSsl = $true | |
$smtp.Credentials = $credentials | |
$smtp.Send($from, $to, $subject, $message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment