Skip to content

Mail Flow

Modify delivery options

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$deliveryOptions = $mailboxParams.MailFlowSettings.DeliveryOptions
$deliveryOptions.IsModificationEnabled = $True

# Update the 'Forward to' parameter
# DN of the group that will receive messages from the mailbox
$groupDN = "CN=Managers,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $groupDN

$deliveryOptions.ForwardingAddress = $objReference

# Enable the 'Deliver message to both forwarding address and mailbox' option
$deliveryOptions.DeliverToMailboxAndForward = $True

# Update Recipients Limits 
$deliveryOptions.RecipientLimits = 10

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Modify message size restrictions

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$messageSizeRestrictions = $mailboxParams.MailFlowSettings.MessageSizeRestrictions
$messageSizeRestrictions.IsModificationEnabled = $True

# Set maximum receiving message size to 25 MB
$maxReceiveSize = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$maxReceiveSize.SetMBytes(25)

$messageSizeRestrictions.MaxReceiveSize = $maxReceiveSize

# Set maximum sending message size to 25 MB
$MaxSendSize = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmByteQuantifiedSize"
$MaxSendSize.SetMBytes(25)
$messageSizeRestrictions.MaxSendSize = $MaxSendSize

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Modify message delivery restrictions

The following code sample configures a mailbox to only accept messages inside its organization.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$messageDeliveryRestrictions = $mailboxParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$messageDeliveryRestrictions.RequireSenderAuthentication = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom.OverrideOldValues = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFromModificationEnabled = $True

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

The following code sample configures a mailbox to accept messages from all senders.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$messageDeliveryRestrictions = $mailboxParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$groupDN = "CN=Sales Staff,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $groupDN

$acceptMessagesOnlyFrom = $messageDeliveryRestrictions.AcceptMessagesOnlyFrom
$acceptMessagesOnlyFrom.OverrideOldValues = $False
$acceptMessagesOnlyFrom.Add("ADS_PROPERTY_APPEND", $objReference)
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom = $acceptMessagesOnlyFrom

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

The following code sample configures a mailbox to only accept messages from a specific group.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$messageDeliveryRestrictions = $mailboxParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$groupDN = "CN=Sales Staff,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $groupDN

$acceptMessagesOnlyFrom = $messageDeliveryRestrictions.AcceptMessagesOnlyFrom
$acceptMessagesOnlyFrom.OverrideOldValues = $False
$acceptMessagesOnlyFrom.Add("ADS_PROPERTY_APPEND", $objReference)
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom = $acceptMessagesOnlyFrom

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

The following code sample configures a mailbox to reject messages from a specific group.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"

$messageDeliveryRestrictions = $mailboxParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$groupDN = "CN=Sales Staff,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $groupDN

$rejectMessagesFrom = $messageDeliveryRestrictions.RejectMessagesFrom
$rejectMessagesFrom.OverrideOldValues = $False
$rejectMessagesFrom.Add("ADS_PROPERTY_APPEND", $objReference)
$messageDeliveryRestrictions.RejectMessagesFrom = $rejectMessagesFrom

# Save changes
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

See also