Contact Sales

All fields are required

Snippet: Text to Email | SignalWire

Snippet: Text to Email

We'll take a regular SMS text message as the input and generate an email as the output!

Applications of this code could be as simple as a 'note to self' or as broad as a gateway for emailing certain people as part of a text-based advertising campaign.

You will need a machine with Python installed, the SignalWire SDK, a provisioned SignalWire phone number, and optionally Docker if you decide to run it in a container.

For this demo, we will be using Python, but more languages may become available.

  • Python
  • SignalWire SDK
  • SignalWire Phone Number
  • MailGun Account (For administrator notifications,
  • Docker (Optional)
Methods and Endpoints
Endpoint: /sms-webhook
Methods: GET OR POST
Endpoint to accept incoming text messages from SignalWire space and forward them to MailGun.

Setup Your Environment File

  1. Copy from example.env and fill in your values
  2. Save new file called .env

Your file should look something like this:

## This is the full name of your SignalWire Space. e.g.:
# Your Project ID - you can find it on the `API` page in your Dashboard.
# Your API token - you can generate one on the `API` page in your Dashboard
# The phone number you'll be using for this Snippets. Must include the `+1` , e$
# MailGun domain associated with your MailGun account
# MailGun token associated with your MailGun Account
# Send Email From Address
# Send email to address for administrator notifications
# Email subject for admin notifications
EMAIL_SUBJECT=Forward Text To Email
Build and Run on Docker

Let's get started!

  • Use our pre-built image from Docker Hub:
For Python:
docker pull signalwire/snippets-text-to-email:python
  • Or build your own image:
docker build -t snippets-text-to-email .
  • Run your image:
docker run --publish 5000:5000 --env-file .env snippets-text-to-email
  • The application will run on port 5000
Build and Run Natively

For Python:

1. Replace environment variables
2. From command line run, python3
More Documentation

You can find more documentation on LaML, Relay, and all SignalWire APIs at:


If you have any issues or want to engage further about this snippet, please open an issue on this repo or join our fantastic Slack community and chat with others in the SignalWire community!

If you need assistance or support with your SignalWire services please file a support ticket from your Dashboard.