Page MenuHomePhabricator

Add a Twilio SMS message adapter

Authored by epriestley on Jan 14 2019, 9:55 PM.
Referenced Files
Unknown Object (File)
Mon, Aug 8, 10:40 AM
Unknown Object (File)
Thu, Aug 4, 11:16 AM
Unknown Object (File)
Tue, Jul 26, 10:29 PM
Unknown Object (File)
Jul 12 2022, 11:16 AM
Unknown Object (File)
Jul 10 2022, 6:36 AM
Unknown Object (File)
Jul 4 2022, 6:32 PM
Unknown Object (File)
Jun 14 2022, 9:39 PM
Unknown Object (File)
Jun 11 2022, 6:26 PM



Ref T920. Adds a "phone number" object, an "SMS" message type, and Twilio glue.

Test Plan

Used this test script to send myself some text messages after configuring Twilio in cluster.mailers.


require_once 'scripts/init/init-script.php';

if ($argc < 3) {
  throw new Exception('usage: test.php <number> <body>');
$to_number = $argv[1];
$text_body = $argv[2];

$mailers = PhabricatorMetaMTAMail::newMailers(
    'outbound' => true,
    'media' => array(
if (!$mailers) {
  return new Aphront404Response();
$mailer = head($mailers);

$message = id(new PhabricatorMailSMSMessage())
  ->setToNumber(new PhabricatorPhoneNumber($to_number))


Diff Detail

rP Phabricator
Lint Not Applicable
Tests Not Applicable

Event Timeline


You should be able to add a similar class to this for AWS SNS now (well, once all this stuff lands), I think.

amckinley added inline comments.

Where did this regex come from? A few minutes of digging for validating of E.123 numbers points to this O'Reilly suggestion:

This revision is now accepted and ready to land.Jan 16 2019, 2:08 AM

I expect this will be refined a lot, but it's more-or-less from the Twilio docs here:

Used this test script to send myself some text messages...

Why not use this to resurrect bin/sms?

The script is currently very bare-metal since PhabricatorMetaMTAMail doesn't actually have the "this might be an SMS" code yet.

That chunk of code is up relatively-soon-ish but I expect it will mean that bin/mail send-test gets a --medium sms or something rather than a separate bin/sms / bin/apns / bin/whatsapp set of entrypoints. I'll see how much of a mess that is, I might resurrect bin/sms if the flags are too confusing (or bin/mail send-short-message-like-sms-or-whatsapp or something). But the "action" bit at the end should be $mail->send(), not $mailer->sendMessage(...).

Doing $mail->send() means that we get retries, a listing in bin/mail list-outbound, an entry in /mail/, non-delivery to disabled users, and a bunch of other support infrastructure stuff.

This revision was automatically updated to reflect the committed changes.