Forward your VoIP Number to another phone and send text messages to email

Given the recent VOIPO shutdown announcement:

Screenshot 2025-08-04 at 2.11.18 PM

and the amount of attention this has gotten on r/voip I figured I would post this to help others who are looking for options. This will require a bit of technical knowledge, but I included every single step required so you could do this yourself. Please make sure you read the entire post before you get started.

What this solution does:

  1. If you receive a call on your phone number, it will be forwarded to a secondary number. The forward is completely blind, if you don’t answer the call it will do whatever your secondary number does when it doesn’t answer. There is no transcription or notification of any kind. It could be added, but that’s outside the scope of this post.
  2. If you receive an SMS message on your phone number, you will receive an email with the contents of said message. There is no response back to the original sender. There is no other notification other than the email you receive. The email will probably go to SPAM, but that’s easy to address.
  3. This has only been tested in the US. I have to imagine other countries would work similarly, but I can’t guarantee anything outside the US.
  4. This solution has no guarantees of any kind. I’ve been using something similar for maybe 10 years and have configured similar solutions for my customers for even longer. However, you are not my customer, but if you want to become my customer head on over to Square O to learn more or send us an email at hello at squareo.com.

Please note that there are NO affiliate links in this post.

Products Used:

  1. We are going to use Twilio for handling a phone call and SMS message. Think of Twilio as a programming platform for telephony services. You can control your calls and text messages with code. Twilio pricing is pretty excellent because it’s very transparent and you have per use charges. Twilio directly replaces VOIPo for example.
  2. We are going to use Mailgun for handling emails. Think of Mailgun as a programming platform for email services. All those promotional emails, news letters, etc. that you get in your inbox come from a provider like Mailgun.

Expected costs:

In our case, let’s assume we get a single call that’s 10 minutes long and 2 text messages. The pricing formula would look like this:

incoming minutes*total minutes + outgoing minutes*total minutes+incoming messages*total messages
($0.0085 / min*10)+($0.0140 / min*10)+($0.0083 / msg*2)=$0.2416 or about 2.5 cents USD.

Note that we are charged for the incoming call and the outgoing call, so we’re paying double for this. It’s important to be aware of this. This is a very common practice on pay as you go platforms.

For email: Mailgun has a very generous free tier of 100 emails per day. This means that if you receive more than 100 text messages per day you would have to sign up for their $15/month plan which allows for 10,000 emails/month. 

Now, there’s one more item which will incur costs and this is the phone number. If you buy a new number or port your number to Twilio you will be charge $1.15/month to hold each phone number. So our total charges based on the example above will be around $1.18/month.

Let’s start building. Prerequisites:

  1. A Mailgun account, you can sign up to a free account via this link.
  2. A Twilio account, you can sign up for a free account via this link. Please note that when you first open an account with Twilio you’re in Trial Mode. Your account needs to NOT be an trial account in order for this to work.
  3. You do not need to port your number until you have everything working, but once you do, you’ll need to submit a porting request. Instructions here.

Twilio Setup for Call Forwarding Only

  1. From the console you’ll want to find Services under Functions and Assets. If you have a new account you will more than likely have to go to Explore products > Developer tools > Functions and Assets.

f0116444-173b-424a-ba89-e90046424d33

2. You will want to Create Service and name it something logical. I chose forwarding-call-sms as my service name.
3. You will then be sent to the function page and see a /welcome in the right hand side. Click the 3 vertical dots and Delete.

Screenshot 2025-08-04 at 3.16.43 PM

4. Click the Add+ button > Add Function.
5.  Name your function /voice and copy and paste the following code.

exports.handler = function(context, event, callback) {
// IMPORTANT: Replace the placeholder number below with your actual forwarding phone number (digits only).

let yourDefaultForwardingNumber = “15551231234”;

// Set the destination phone number.
// It will use the number from the incoming event if it exists,
// otherwise it constructs the full number from your default.
let destinationPhoneNumber = event.PhoneNumber || `+${yourDefaultForwardingNumber}`;

// Generate the TwiML to tell Twilio how to forward this call
let twiml = new Twilio.twiml.VoiceResponse();

let dialParams = {};

// The <Dial> TwiML verb is used to connect the current call to a new number
twiml.dial(dialParams, destinationPhoneNumber);

// Return the TwiML to Twilio
callback(null, twiml);
};

6. Update the line that start with let yourDefaultForwardingNumber with your 10 digit phone number starting with 1.
7. Hit Save
8. Hit Deploy All and you should see something like this.

Aug 4, 2025, 03:24:33 PM Saving function path: /voice…
Aug 4, 2025, 03:24:34 PM Saved function: /voice
Aug 4, 2025, 03:24:46 PM Starting build…
Aug 4, 2025, 03:24:47 PM Completed…
Aug 4, 2025, 03:25:02 PM Build completed
Aug 4, 2025, 03:25:02 PM Deploying…
Aug 4, 2025, 03:25:03 PM Deployed to environment: forwarding-call-sms-…

9. From the console you’ll want to find the Buy a number under Phone Numbers > Manage. You can choose different types of phone numbers based on all sorts of criteria. To get started pick any local number that supports Voice and SMS. Once purchased you’ll want to go to Active Numbers and click on it to configure the function we wrote to be triggered every time a call arrives.

2c2cc12b-b311-43e8-bfcf-77ba030d45a7
10.Under Voice Configuration you’ll want your configuration to look like this.

Screenshot 2025-08-04 at 3.32.16 PM

11. Click Save configuration and you are done. 
12. Place a test call and see what happens.

Mailgun and Twilio Setup for Call SMS to Email Only

  1. Login to your Mailgun dashboard and go to Sending > Domains. The domain should look something like sandboxXYZ.mailgun.org. Copy the domain and save it for later use.
  2. Click on your sandbox domain and go to Setup.
  3. Add the email address of who will receive the SMS emails and send invite. You must click on the I Agree link you get in your inbox to ensure emails will be sent to you via Mailgun.

Screenshot 2025-08-04 at 11.04.20 PM

3. Under Sending keys add a sending key and copy the Sending API key and save it for later use.
4. Go back to Twilio > Functions and click on the function you used on the first step.
5. Add a new function called /sms and add the following code and Save.

exports.handler = function(context, event, callback) {
constAPI_KEY = context.MAILGUN_API_KEY;
constDOMAIN = context.MAILGUN_DOMAIN;

const formData = require(‘form-data’);
constMailgun = require(‘mailgun.js’);

const mailgun = newMailgun(formData);
const client = mailgun.client({username: ‘api’, key: API_KEY});

const messageData = {
from: context.FROM_EMAIL,
to: context.TO_EMAIL,
subject: `New SMS message from: ${event.From}`,
text: event.Body
};

client.messages.create(DOMAIN, messageData)
.then((res) => {
let twiml = newTwilio.twiml.MessagingResponse();
callback(null, twiml);
})
.catch((err) => {
console.error(err);
callback(err);
});
};
6. Click on Dependencies and add the following two exactly as you see the below.

mailgun.js

11.1.0

form-data4.0.1

7. Click on Environment Variables and add the following 4 variables with your respective values.

FROM_EMAIL

your@email.com

TO_EMAILyour@email.com
MAILGUN_API_KEY

Key saved from step 3 above.

MAILGUN_DOMAINDomain saved from step 1.

8. Deploy all
9. From the console you’ll want to find your phone number under Phone Numbers > Manage. You’ll want to set up your messaging configuration to look like this.

Screenshot 2025-08-04 at 11.35.41 PM

10. Click Save configuration and you are done. 
11. Send a text message to your Twilio number and check your spam folder. You should see an email like the one below.

 

Screenshot 2025-08-04 at 11.32.51 PM

Good luck.

~david