Create SMTP Profiles with Powershell (RESTful API)

Has anyone experiences with creating SMTP Profiles via RESTful API?

I scripted it with Powershell and it seems, that it works. I see the profile in the WebAdmin-Interface, it shows exactly the choosen values.

But it don't work. Trying to send a mail generates an error 'Relay not permitted'.

When I opened the profile in WebAdmin and save it even without changing any value, the profile worked and I get no errors sending mails.

Is there a special activation nessessary? Deactivate und Activate in WebAdmin has no effects, only saving the profile.

Here is the script code:

    $token = 'sophos api token'
    $token = 'diuuPpLspiabMKvVDEdDhwlJgTMIMsMv'
    $tokenBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes("token:" + $token))
    $headers = @{}
    $headers.add("Authorization",'Basic ' + $tokenBase64)
    $headers.add("Content-Type", "application/json")
    $headers.add("Accept", "application/json")
    $uri="https://<sophos-ip>:4444/api/objects/smtp/profile/"
    $uri="10.47.100.42:4444/.../"
    $domain="somedomain.com"
    $profile_name=$domain
    $routehost_ref="REF_NetHosxxxxxxx"
    $routehost_ref="REF_NetHosMbox02inby"
    $ProfileBody = @{
        "cff_av" = "blackhole";
        "cff_av_engines" = "double";
        "cff_file_extensions" =  @();
        "comment" = "created via Sophos API, $(Get-Date)";
        "domains" = @( $domain );
        "global_copy" = @( "rcpt_verify"; "rbl"; "rbl_extra"; "misc"; "av"; "as"; "sender_blacklist"; "mime"; "mime_blacklist"; "mime_whitelist"; "extensions"; "expressions"; "confidential_footer"; "spx_template"; "data_protection"; "header_modification" );
        "name" = "$profile_name";
        "rdns_reject" = $false;
        "route_list" =  @( $routehost_ref );
        "spam" = "blackhole";
        "spamplus" = "blackhole";
        "spx_template" = "";
        "status" = $true;
    }
    Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -body (ConvertTo-Json $ProfileBody)


Thanks for any help!

  • Hallo and welcome to the UTM Community!

    This feels like a minor bug.  What does Sophos Support have to say about this?

    Cheers - Bob