Send SMS Programmatically

Please provide the following:

  1. SDK Version: 2.11.2
  2. Platforms(ios/android/both): both

Hi All, I hope this is the right place to raise my query–if not I’m happy to move this elsewhere.

I’m looking to periodically send reminder text messages as a background process. I tried SMS.sendSMSAsync(), which is awesome, but this pulls up the default SMS service on the host and requires the user to submit the send button. That’s not fatal but it’d be nicer to do this in the background.

I have started exploring sending SMS programmatically from a simple server-side Python, ala:

import smtplib
import email.mime.multipart

sender = ''

# Establish a secure session with gmail's outgoing SMTP server using your gmail account
server = smtplib.SMTP('', 587)
server.login(sender, YOUR_PASSWORD_GOES_HERE)

msg = '\r\n'.join([
  'MIME-Version: 1.0',
  #'Date: Fri, 22 Feb 2019 11:29:27 -0500',
  #'Message-ID: 12345678',
  'Subject: cartes', # shows up in bold at top of message
  'From: Douglas Duhaime <>',
  'Content-Type: multipart/alternative; boundary="0000000000003c664305827e1862"',
  'Content-Type: text/plain; charset="UTF-8"',
  'message from dd',

# sendmail(from, to, msg)
server.sendmail('', '', msg)

That indeed sends me a text message, but requires me to know the service provider of the recipient, and shows the sender as, while I’d like the user’s phone to show up as the sender.

Is there a straightforward way to send a message programmatically with expo or related server-side code? I’d be grateful for any advice others can offer on this question.


FYI 2.11.2 looks like the version of the Expo app rather than the SDK version. The app supports a range of SDK versions. The SDK version would be in your app.json file. If you’ve just created a new app with an up to date version of expo-cli then it would be version 34.

The Python code you posted is basically just sending an email to some service that presumably sends the sms on your behalf. So whether you can change the sender etc. would depend on that service. This has nothing to do with Expo.

If that service doesn’t work for you maybe there’s another SMS provider that will work for you.


1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.