============================================================================= # Test script for SmarterMail API - SetDomainSettings (blockedCountriesAtAuth) # ============================================================================= # CONFIGURATION - Modify these values $serverUrl = "https://your-smartermail-server.com" # SmarterMail server URL $username = "admin@domain.com" # System administrator username $password = "your-password" # Password $testDomain = "example.com" # Domain to modify # Countries to set as "accepted" (type=2) # type=1 = Blocked (reject these countries) # type=2 = Unblocked (accept only these countries) $listType = 2 $countries = "IT,DE,FR" # ============================================================================= # STEP 1: Authentication # ============================================================================= Write-Host "=== STEP 1: Authentication ===" -ForegroundColor Cyan $authUrl = "$serverUrl/api/v1/auth/authenticate-user" $authBody = @{ username = $username password = $password } | ConvertTo-Json try { $authResponse = Invoke-RestMethod -Uri $authUrl -Method Post -Body $authBody -ContentType "application/json" $accessToken = $authResponse.accessToken if (-not $accessToken) { Write-Host "ERROR: Token not received" -ForegroundColor Red Write-Host "Response: $($authResponse | ConvertTo-Json -Depth 5)" exit 1 } Write-Host "Authentication OK - Token received" -ForegroundColor Green } catch { Write-Host "Authentication ERROR: $_" -ForegroundColor Red exit 1 } # ============================================================================= # STEP 2: Retrieve current domain settings (GET) # ============================================================================= Write-Host "" Write-Host "=== STEP 2: GET current domain settings ===" -ForegroundColor Cyan $headers = @{ "Authorization" = "Bearer $accessToken" "x-smartermaildomain" = $testDomain } $getUrl = "$serverUrl/api/v1/settings/domain/domain" try { $getResponse = Invoke-RestMethod -Uri $getUrl -Method Get -Headers $headers Write-Host "GET OK" -ForegroundColor Green # Show current blockedCountriesAtAuth settings if ($getResponse.domainSettings.blockedCountriesAtAuth) { Write-Host "Current blockedCountriesAtAuth settings:" Write-Host " type: $($getResponse.domainSettings.blockedCountriesAtAuth.type)" Write-Host " countries: $($getResponse.domainSettings.blockedCountriesAtAuth.countries)" } } catch { Write-Host "GET ERROR: $_" -ForegroundColor Red } # ============================================================================= # STEP 3: Try to modify settings (POST) # ============================================================================= Write-Host "" Write-Host "=== STEP 3: POST modify settings ===" -ForegroundColor Cyan # Documented endpoint: POST api/v1/settings/sysadmin/domain-settings/{domain} $postUrl = "$serverUrl/api/v1/settings/sysadmin/domain-settings/$testDomain" $postHeaders = @{ "Authorization" = "Bearer $accessToken" "Content-Type" = "application/json" } # Body according to documentation $postBody = @{ domainSettings = @{ blockedCountriesAtAuth = @{ type = $listType countries = $countries } } } | ConvertTo-Json -Depth 5 Write-Host "URL: $postUrl" Write-Host "Body:" Write-Host $postBody try { $postResponse = Invoke-RestMethod -Uri $postUrl -Method Post -Headers $postHeaders -Body $postBody Write-Host "POST OK!" -ForegroundColor Green Write-Host "Response: $($postResponse | ConvertTo-Json -Depth 5)" } catch { Write-Host "POST ERROR: $_" -ForegroundColor Red if ($_.Exception.Response) { $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream()) $responseBody = $reader.ReadToEnd() Write-Host "Response Body: $responseBody" -ForegroundColor Yellow } } # ============================================================================= # STEP 4: Alternative attempt with PUT # ============================================================================= Write-Host "" Write-Host "=== STEP 4: Try PUT on alternative endpoint ===" -ForegroundColor Cyan $putUrl = "$serverUrl/api/v1/settings/domain/domain" $putHeaders = @{ "Authorization" = "Bearer $accessToken" "Content-Type" = "application/json" "x-smartermaildomain" = $testDomain } Write-Host "URL: $putUrl" Write-Host "Header x-smartermaildomain: $testDomain" try { $putResponse = Invoke-RestMethod -Uri $putUrl -Method Put -Headers $putHeaders -Body $postBody Write-Host "PUT OK!" -ForegroundColor Green Write-Host "Response: $($putResponse | ConvertTo-Json -Depth 5)" } catch { Write-Host "PUT ERROR: $_" -ForegroundColor Red if ($_.Exception.Response) { $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream()) $responseBody = $reader.ReadToEnd() Write-Host "Response Body: $responseBody" -ForegroundColor Yellow } } # ============================================================================= # STEP 5: Try with minimal body # ============================================================================= Write-Host "" Write-Host "=== STEP 5: Try POST with body without domainSettings wrapper ===" -ForegroundColor Cyan $minimalBody = @{ blockedCountriesAtAuth = @{ type = $listType countries = $countries } } | ConvertTo-Json -Depth 5 Write-Host "Minimal body:" Write-Host $minimalBody try { $minResponse = Invoke-RestMethod -Uri $postUrl -Method Post -Headers $postHeaders -Body $minimalBody Write-Host "Minimal POST OK!" -ForegroundColor Green Write-Host "Response: $($minResponse | ConvertTo-Json -Depth 5)" } catch { Write-Host "Minimal POST ERROR: $_" -ForegroundColor Red if ($_.Exception.Response) { $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream()) $responseBody = $reader.ReadToEnd() Write-Host "Response Body: $responseBody" -ForegroundColor Yellow } } Write-Host "" Write-Host "=== END OF TEST ===" -ForegroundColor Cyan Write-Host "Attach this output to the SmarterMail support ticket"
By reporting abuse, a moderator will be asked to review the content of this interaction to take further action, if necessary.
# ============================================================================= # Test script for SmarterMail API - SetDomainSettings (blockedCountriesAtAuth) # ============================================================================= # CONFIGURATION - Modify these values $serverUrl = "https://your-smartermail-server.com" # SmarterMail server URL $username = "admin@domain.com" # System administrator username $password = "your-password" # Password $testDomain = "example.com" # Domain to modify # Countries to set as "accepted" (type=2) # type=1 = Blocked (reject these countries) # type=2 = Unblocked (accept only these countries) $listType = 2 $countries = @("IT", "DE", "FR") # ============================================================================= # STEP 1: Authentication # ============================================================================= Write-Host "=== STEP 1: Authentication ===" -ForegroundColor Cyan $authUrl = "$serverUrl/api/v1/auth/authenticate-user" $authBody = @{ username = $username password = $password } | ConvertTo-Json try { $authResponse = Invoke-RestMethod -Uri $authUrl -Method Post -Body $authBody -ContentType "application/json" $accessToken = $authResponse.accessToken if (-not $accessToken) { Write-Host "ERROR: Token not received" -ForegroundColor Red Write-Host "Response: $($authResponse | ConvertTo-Json -Depth 5)" exit 1 } Write-Host "Authentication OK - Token received" -ForegroundColor Green } catch { Write-Host "Authentication ERROR: $_" -ForegroundColor Red exit 1 } # ============================================================================= # STEP 2: Retrieve current domain settings (GET) # ============================================================================= Write-Host "" Write-Host "=== STEP 2: GET current domain settings ===" -ForegroundColor Cyan $headers = @{ "Authorization" = "Bearer $accessToken" "x-SmarterMailDomain" = $testDomain } $getUrl = "$serverUrl/api/v1/settings/domain/domain" try { $getResponse = Invoke-RestMethod -Uri $getUrl -Method Get -Headers $headers Write-Host "GET OK" -ForegroundColor Green # Show current blockedCountriesAtAuth settings if ($getResponse.domainSettings.blockedCountriesAtAuth) { Write-Host "Current blockedCountriesAtAuth settings:" Write-Host " type: $($getResponse.domainSettings.blockedCountriesAtAuth.type)" Write-Host " countries: $($getResponse.domainSettings.blockedCountriesAtAuth.countries)" } } catch { Write-Host "GET ERROR: $_" -ForegroundColor Red } # ============================================================================= # STEP 3: Try to modify settings (POST) # ============================================================================= Write-Host "" Write-Host "=== STEP 3: POST modify settings ===" -ForegroundColor Cyan # Documented endpoint: POST api/v1/settings/domain/domain # See https://mail.smartertools.com/Documentation/api#/reference/SmarterMail.Web.Api.DomainSettingsController/SetDomainSettings/post $postUrl = "$serverUrl/api/v1/settings/domain/domain" $postHeaders = @{ "Authorization" = "Bearer $accessToken" "Content-Type" = "application/json" "X-SmarterMailDomain" = $testDomain } # Body according to documentation $postBody = @{ domainSettings = @{ blockedCountriesAtAuth = @{ type = $listType countries = $countries } } } | ConvertTo-Json -Depth 5 Write-Host "URL: $postUrl" Write-Host "Body:" Write-Host $postBody try { $postResponse = Invoke-RestMethod -Uri $postUrl -Method Post -Headers $postHeaders -Body $postBody Write-Host "POST OK!" -ForegroundColor Green Write-Host "Response: $($postResponse | ConvertTo-Json -Depth 5)" } catch { Write-Host "POST ERROR: $_" -ForegroundColor Red if ($_.Exception.Response) { $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream()) $responseBody = $reader.ReadToEnd() Write-Host "Response Body: $responseBody" -ForegroundColor Yellow } } Write-Host "" Write-Host "=== END OF TEST ===" -ForegroundColor Cyan Write-Host "Attach this output to the SmarterMail support ticket"
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add noreply@smartertools.com to your trusted senders list in your email software.
A code was sent to the recovery email address. Please provide the 6-digit code.
A code can be retrieved from your authentication app. Please provide the 6-digit code.
An email was sent to your recovery email address. If you need further assistance, please contact your system admin.