18 lines
674 B
PowerShell
18 lines
674 B
PowerShell
param(
|
|||
|
|
[Parameter(Mandatory = $true)][string]$Smtp,
|
||
|
|
[int]$Port = 465,
|
||
|
|
[Parameter(Mandatory = $true)][string]$From,
|
||
|
|
[Parameter(Mandatory = $true)][string]$To,
|
||
|
|
[Parameter(Mandatory = $true)][string]$User,
|
||
|
|
[Parameter(Mandatory = $true)][string]$Pass,
|
||
|
|
[Parameter(Mandatory = $true)][string]$Subject,
|
||
|
|
[Parameter(Mandatory = $true)][string]$Body
|
||
|
|
)
|
||
|
|
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
$secure = ConvertTo-SecureString $Pass -AsPlainText -Force
|
||
|
|
$cred = New-Object System.Management.Automation.PSCredential($User, $secure)
|
||
|
|
|
||
|
|
Send-MailMessage -SmtpServer $Smtp -Port $Port -UseSsl `
|
||
|
|
-From $From -To $To -Subject $Subject -Body $Body `
|
||
|
|
-Encoding UTF8 -Credential $cred
|