'Can't receive SMS message with Twilio trial account

I have a small project (Express) using a Twilio trial account to send an SMS message to my phone number. But when I use my own message to replace the example string, I can't receive the SMS anymore.

This is what I tried:

  • Verified my own number, so the Twilio phone number can send SMS messages to my own phone number.
  • Verified the token and sid are the live credentials, not the testing one.
  • Check the SMS Log, and the status of all messages are sent. But again, I don't receive anything.
  • Used postman to verify the route if it is working properly. And yes, it did.

This is my code for the route to call the function to send the SMS

router.post("/contacts/sms", authorization, async (req, res) => {
  try {
    const { phone, message } = req.body;
    **sendSms(phone, message);**
    res.status(201).send({
      message:
        "Account created successfully, kindly check your phone to activate your account!",
    });
  } catch (error) {
    res.status(500).send("Server error");
  }
});

This is the SMS function

require("dotenv").config();

const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN; 

const sendSms = (phone, message) => {
  const client = require("twilio")(accountSid, authToken);
  client.messages
    .create({
      body: message,
      from: process.env.TWILIO_PHONE_NUMBER,
      to: phone,
    })
    .then((message) => console.log(message.sid));
};

module.exports = sendSms;


Solution 1:[1]

I have answered a similar question, you might wanna have a look at that https://stackoverflow.com/a/71912348/17503984

The problem might be since your Twilio phone number and the number you are sending are from different nationalities, communication problems arise due to the international SMS service

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Unni Krishnan