0
我無法在Google或Mailgun支持上找到任何有關如何使用Powershell發送附件的答案。發送沒有附件的郵件適用於Mailgun和Powershell。這是我的代碼。使用Powershell發送帶有Mailgun的附件
$apikey = "key-1342323f7d35352fa4dda3af3ca10e"
$idpass = "api:$($apikey)"
$basicauth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($idpass))
$headers = @{
Authorization = "Basic $basicauth";
}
$url = "https://api.mailgun.net/v3/sandboxac77741768d442323b96495501ac24b.mailgun.org/messages"
$mailbody = @{
from = "Mailgun Sandbox <[email protected]>";
to = "[email protected]";
subject = "Testing mail";
text = "Email body here";
attachment = "D:\temp\logfile.txt"
}
Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $mailbody -ContentType "multipart/form-data"
這導致: 調用-RestMethod:遠程服務器返回錯誤:(400)錯誤的請求
如果這是您的實際API密鑰,您可能想繼續並立即撤銷它:-) –
這不是我的實際:) –