Created
February 5, 2023 08:43
-
-
Save Apoc70/67419eaa6fc7ec4b7c955dadb1d72fa3 to your computer and use it in GitHub Desktop.
This PowerShell script creats an Exchange Online inbound and outbound connector, and adds a transport rulle for the outbound connector.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name of the on-premises SMTP gateway | |
$GatewayName = 'NoSpamProxy' | |
# TLS certificate common name for incoming connection to EOP | |
$InboundTlsCN = 'smpto.varunagroup.de' | |
# TLS certificate common name for outgoing connection to EOP | |
$OutboundTlsCN = 'smpto.varunagroup.de' | |
# Fully qualified domain name (FQDN) of the on-premises SMTP gateway | |
$SmartHostFqdn = 'smtpo.varunagroup.de' | |
# Create OUTBOUND connector from your on-premises SMTP gateway to | |
# your Office 365 tenant allowing all SMTP domains for inbound traffic | |
New-InboundConnector -Name ('Inbound from {0}' -f $GatewayName) ´ | |
-TlsSenderCertificateName $InboundTlsCN ´ | |
-RequireTls $true -SenderDomains * ´ | |
-RestrictDomainsToCertificate $true | |
# Create OUTBOUND connector from your Office 365 to your on-premises SMTP gateway | |
# for use by a transport rule using a dedicated target smart host FQDN and | |
# securing the connection using TLS domain validation | |
New-OutboundConnector -Enabled $true -IsTransportRuleScoped $true ´ | |
-Name ('Outbound to {0}' -f $GatewayName) ´ | |
-TlsSettings DomainValidation ´ | |
-TlsDomain $OutboundTlsCN ´ | |
-ConnectorType Partner ´ | |
-SmartHosts $SmartHostFqdn ´ | |
-UseMXRecord $false | |
# Create an EXO transport rule to send all mail message to recipients outside the | |
# Exchange organization using the new outbound connector | |
New-TransportRule -Name ('Outbound Mails to {0}' -f $GatewayName) ´ | |
-SentToScope NotInOrganization ´ | |
-RouteMessageOutboundConnector ('Outbound to {0}' -f $GatewayName) | |
# Create an EXO transport role to set the Spam Confidence Level for incoming | |
# external messages to -1 | |
New-TransportRule -SetSCL "-1" -FromScope NotInOrganization ´ | |
-Name 'Disable Spam filtering for inbound emails' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment