Email Address Validation
Code Properties
- Language: PowerShell
- Cmdlets:
Invoke-RestMethod
Overview
Sources:
Simple PowerShell script that validates email addresses using the MailCheck API via RapidAPI.
Code
$headers = @{}
$headers.Add("x-rapidapi-host", "mailcheck.p.rapidapi.com")
$headers.Add("x-rapidapi-key", "YOUR-API-KEY")
$response = Invoke-RestMethod -Uri 'https://mailcheck.p.rapidapi.com/?domain=EMAIL-OR-DOMAIN' -Method GET -Headers $headersUsage
Replace YOUR-API-KEY with your RapidAPI key and specify the email or domain to validate:
$headers = @{
"x-rapidapi-host" = "mailcheck.p.rapidapi.com"
"x-rapidapi-key" = "your-api-key-here"
}
$email = "test@example.com"
$response = Invoke-RestMethod -Uri "https://mailcheck.p.rapidapi.com/?domain=$email" -Method GET -Headers $headers
# check results
if ($response.valid) {
Write-Host "Email is valid" -ForegroundColor Green
} else {
Write-Host "Email is invalid" -ForegroundColor Red
}Appendix
Note created on 2024-05-20 and last modified on 2024-12-31.
See Also
Backlinks
(c) No Clocks, LLC | 2024