This Python script makes it easy to discover if your outgoing SMTP server is being blocked by Microsoft's Outlook.com email infrastructure. It queries the Smart Network Data Service API and alerts you via email if any of your SMTP servers are blacklisted by Microsoft.
When the script detects that one of your IPs is blocked, it will notify the recipients configured in your .env
via email:
recipients:
- name: Jane Doe
email: [email protected]
- name: Jon Doe
email: [email protected]
The notification looks something like this:
While administrating multiple small email servers, I experienced that Microsoft is pretty aggressive in their
blacklisting of outgoing SMTP servers even though they might rarely see any traffic from them. The result is that
your users cannot reach any email addresses ending with @hotmail.com
, @outlook.com
and some others. Unfortunately,
Microsoft does not share why they block certain IP addresses or IP ranges. Since I don't have any problems with any
other email hosting providers whatsoever, I have to assume my SMTP servers are being unfairly targeted. I have checked
my logs every time Microsoft decided to block any of my servers' IPs, by the way. Nothing "spammy" was ever sent from
those machines.
My solution is this script that queries the API of Outlook's Smart Network Data Service and alerts me if any of my registered IPs currently being blocked by their system.
The first step is to register at Outlook.com's Smart Network Data Service on their
website. Next, associate our IP (ranges) with your account on
the Request Access tab. Now go to the Edit Profile tab and click on the link to change your
automated access settings under Automated Access. Enable automated access and save the API key that is generated.
The API key's format looks like this: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
To install the software, you have to perform the following steps:
- Clone the repository.
git clone https://github.com/martbock/outlook-postmaster-query.git cd outlook-postmaster-query/
- Create a virtual environment, activate it and install the dependencies.
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
- Copy the
env.example.yml
file toenv.yml
. This yaml-formatted file holds your specific configuration.cp env.example.yml env.yml nano env.yml
- Enter the API Key at the config path
outlook.api.key
. - Run the script to check for syntactical correctness of your configuration file.
python3 app.py
- Create a cron job for automatically running the query.