How to use sendSMS sketch?

Hi, everyone, I am trying to use the sketch (sendSMS) to send a message to my phone. But as the results shows, my phone didn't receive it. Do anybody know how to send an SMS by using this sketch or using AT command? Thanks in advance!

11:40:17.100 -> SMS Messages Sender
11:40:24.845 -> NB initialized
11:40:24.845 -> Enter a mobile number: +4407762311049
11:40:45.409 -> Now, enter SMS content: SENDING
11:41:11.497 -> 
11:41:11.497 -> Message:
11:41:11.497 -> 313131
11:44:11.518 -> 

Please post your code following the advice given in the link below

Here is the code

/*
 SMS sender

 This sketch, for the MKR NB 1500 board, sends an SMS message
 you enter in the serial monitor. Connect your Arduino with the
 SIM card, open the serial monitor, and wait for
 the "READY" message to appear in the monitor. Next, type a
 message to send and press "return". Make sure the serial
 monitor is set to send a newline when you press return.

 Circuit:
 * MKR NB 1500 board
 * Antenna
 * SIM card that can send SMS

 created 25 Feb 2012
 by Tom Igoe
*/

// Include the NB library
#include <MKRNB.h>

#include "arduino_secrets.h" 
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// PIN Number
const char PINNUMBER[] = SECRET_PINNUMBER;

// initialize the library instance
NB nbAccess;
NB_SMS sms;

void setup() {
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("SMS Messages Sender");

  // connection state
  bool connected = false;

  // Start NB module
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while (!connected) {
    if (nbAccess.begin(PINNUMBER) == NB_READY) {
      connected = true;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("NB initialized");
}

void loop() {

  Serial.print("Enter a mobile number: ");
  char remoteNum[20];  // telephone number to send SMS
  readSerial(remoteNum);
  Serial.println(remoteNum);

  // SMS text
  Serial.print("Now, enter SMS content: ");
  char txtMsg[200];
  readSerial(txtMsg);
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);

  // send the message
  sms.beginSMS(remoteNum);
  sms.print(txtMsg);
  sms.endSMS();
  Serial.println("\nCOMPLETE!\n");
}

/*
  Read input serial
 */
int readSerial(char result[]) {
  int i = 0;
  while (1) {
    while (Serial.available() > 0) {
      char inChar = Serial.read();
      if (inChar == '\n') {
        result[i] = '\0';
        Serial.flush();
        return 0;
      }
      if (inChar != '\r') {
        result[i] = inChar;
        i++;
      }
    }
  }
}

I tried to use AT+command to realize this function, the problem is when i am using AT+CGSM, after typing in my destination address and , I input the message I want to send and , I failed here. No response from my modem.


+CMGF: 1

OK
AT+CMGS="1234"

> 31

What's wrong with it?

I'm throwing this out since no one has replied. I am using a different cellular modem, but in order to send the message, a Crtl+Z is used. So with my hardware, once I enter the phone number and receive the > response, I enter the message, then Ctrl+Z to send. This does not work with the serial monitor in the Arduino IDE. I connect using TeraTerm and it works fine.