SMS Twilio Gateway

By simply creating a Twilio account and adding the necessary details into surgemail.ini you can instantly get SMS Notification and Password recovery features. This lets users send themselves notification's based on incoming email messages that match certain criteria. And use SMS for password recovery if they forget their login details. A free Twilio trial account can even be used to test this with.

Create a Twilio account

(Note the above link is a referral link).

Copy your SID, Token and Phone number.

Login to your Twilio console, on the dashboard you will find:

Account SID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Auth Token: xxxxxxxxxxxxxxxxxxxxxxxxxx

And if you go to the phone numbers tab, you should have a phone number, if not you will need to add one:

Phone Number +1xxxxxxxxxx

Copy these three things into your surgemail.ini settings:

g_twilio_from "+13xxxxxxx"
g_twilio_sid "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
g_twilio_token "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Test the SMS gateway is working

tellmail sms_test +1nnnnnnnnn (your cell phone number)

Within 30 seconds you should get a test message.

Configure your personal phone number

Lookup your account, click on 'password' and configure your SMS number, or in the admin console just fill in the 'sms_to' setting, be sure to specify your full phone number including + and international code, e.g. for U.S. numbers +1.... for New Zealand it would be +64....


Now if you go to surgeweb login and press 'forgot' you should be able to use an SMS confirmation to reset your password:


Add SMS notification rules

First add user_sms "true" to each domain:

user_sms "true"

Lookup your account, go to the 'sms' config page, and add a rule.

if Subject contains Urgent

Now send yourself an email with the subject "Urgent issue". It should arrive on your phone.

Configure a quota rule

Add a default number of messages per user per day, this is a domain level setting so will need to be added to each domain:

user_sms_quota initial="10" period="24"

Typically SMS messages cost about 1 cent, so factor this into your cost structure to decide what sort of limits you need. This limit only applies to the notify feature. Password resets do not count against the users SMS quota.

Was this article helpful?

Related Articles