Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

How to send SMS via Python using SMPPLIB? or other smpp libs?

$
0
0

Could you help with sms sending via smpp directly to SMPP server(SMSC). I need python code.ChatGpt generated below code, can you evaluate the correctness

from smpplib.client import Clientfrom smpplib.sm import SMPPCommandfrom smpplib import consts# Replace these values with your SMPP server detailssmpp_host = 'your_smpp_server_host'smpp_port = your_smpp_server_portsmpp_username = 'your_smpp_username'smpp_password = 'your_smpp_password'# Create an SMPP clientclient = Client(smpp_host, smpp_port)# Bind to the SMPP serverclient.connect()client.bind_transceiver(system_id=smpp_username, password=smpp_password)# Replace these values with the recipient's phone number and the message you want to senddestination_number = 'recipient_phone_number'message_text = 'Your SMS message text here'# Prepare the SMS messagemessage = client.send_message(    source_addr_ton=consts.SMPP_TON_INTL,    source_addr_npi=consts.SMPP_NPI_ISDN,    source_addr='your_sender_number',    dest_addr_ton=consts.SMPP_TON_INTL,    dest_addr_npi=consts.SMPP_NPI_ISDN,    destination_addr=destination_number,    short_message=message_text,    data_coding=consts.SMPP_ENCODING_ISO10646)# Print the message ID if the message was sent successfullyif message['header']['command_status'] == consts.SMPP_ESME_ROK:    print(f"Message sent successfully. Message ID: {message['message_id']}")else:    print(f"Failed to send message. Status: {message['header']['command_status']}")# Unbind and disconnect from the SMPP serverclient.unbind()client.disconnect()

I have IP, Port, Login/Pass, Alpha name

If it's not correct, please share right one pls.


Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>