-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSend-MailJetMail.ps1
More file actions
35 lines (33 loc) · 903 Bytes
/
Copy pathSend-MailJetMail.ps1
File metadata and controls
35 lines (33 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function Send-MailJetMail {
[cmdletbinding()]
param(
[string]$Sender,
[string]$Recipient,
[string]$Subject,
[string]$Text,
[string]$User,
[string]$Key
)
$body = [ordered]@{
Messages= @(@{
to = @(@{email = $recipient})
from = @{email = $Sender ; name = "notification"}
subject = $Subject
TextPart = $Text
})
}
$userkey = $user,$key -join ":"
$auth = $userkey | ConvertTo-Base64
$param = @{
Uri = "https://api.mailjet.com/v3.1/send"
ContentType = "application/json"
body = ($body | ConvertTo-Json -Depth 4 -Compress)
Method = "POST"
Headers = @{Authorization=("Basic $auth")}
UseBasicParsing = [switch]::Present
}
$Result = Invoke-RestMethod @param
if($Result) {
$Result.Messages
}
}