Last active
January 2, 2023 17:36
-
-
Save ctigeek/d79484ccbaec7e71a837 to your computer and use it in GitHub Desktop.
Send an email using Mailgun in 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
function Send-MailgunEmail($from, $to, $subject, $body, $emaildomain, $apikey) { | |
$idpass = "api:$($apikey)" | |
$basicauth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($idpass)) | |
$headers = @{ | |
Authorization = "Basic $basicauth" | |
} | |
$url = "https://api.mailgun.net/v2/$($emaildomain)/messages" | |
$body = @{ | |
from = $from; | |
to = $to; | |
subject = $subject; | |
text = $body | |
} | |
Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body | |
} |
anyways to add attachment to email using mailgun ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ahhh ok. Tremendous help. Thank you!