We’ve switched SMS providers at work to Nexmo, however they don’t have a SMTP API. I whipped up a quick EWS script to monitor a mailbox for emails in the correct format and to send SMS’ based off it. Script below.

The script should be run as the user whos mailbox will be monitored (ours is set up as a scheduled task). Next, it should have to subfolders called “Error” and “Processed”. Successful emails get marked as read and send to “Processed”, and unsuccessful emails get kept as unread and moved to “Error”. Because we send from some systems that don’t have SMTP authentication, there is a field called “Secret” that should be defined at the top of the PowerShell script and put in each email.

The format for the email is:

1
2
3
4
From: fromuser
To: number in international format (ie. +61404040404)
Text: any text here
Secret: secret code defined in script

The script is set to run every 20 seconds.