fiorix / go-smpp

SMPP 3.4 Protocol for the Go programming language
MIT License
220 stars 136 forks source link

Error sending SMS with Golang SMPP protocol: Unknown address #119

Closed JimcaaleAaqil closed 1 year ago

JimcaaleAaqil commented 1 year ago

I'm using a simple Go app to send SMPP SMS. The messages are being sent successfully, but the source address displayed on the recipient's phone is "Unknown address". Here is my code

-- main.go

package main

import (
    "log"

    "github.com/fiorix/go-smpp/smpp"
    "github.com/fiorix/go-smpp/smpp/pdu/pdufield"
    "github.com/fiorix/go-smpp/smpp/pdu/pdutext"
)

func main() {
    tx := &smpp.Transmitter{
        Addr:   "server:port",
        User:   "userId",
        Passwd: "password",
    }
    // Create persistent connection, wait for the first status.
    conn := <-tx.Bind()
    if conn.Status() != smpp.Connected {
        log.Fatal(conn.Error())
    }
    sm, err := tx.Submit(&smpp.ShortMessage{
        Src:      "MyCompany",
        Dst:      "25*********",
        Text:     pdutext.Raw("Sample sms"),
        Register: pdufield.NoDeliveryReceipt,
    })
    if err != nil {
        log.Fatal(err)
    }
    log.Println("Message ID:", sm.RespID())
}

-- go.mod

module sms
go 1.21.0
require github.com/fiorix/go-smpp v0.0.0-20210403173735-2894b96e70ba
require golang.org/x/text v0.3.6 // indirect

smpp

JimcaaleAaqil commented 1 year ago

Just added this 2 fields and now it works!

sm, err := tx.Submit(&smpp.ShortMessage{
    Src:      "MyCompany",
    Dst:      "25*********",
    Text:     pdutext.Raw("Sample sms"),
    Register: pdufield.NoDeliveryReceipt,
    // ADDED THESS 2 FIELDS
    SourceAddrTON: 5,
    SourceAddrNPI: 0,
})