How to send SMS using Net :: SMPP in Perl?

I am trying to send an SMPP message using Net :: SMPP , but it gives an error below:

Message state is 2 Response indicated error: Message ID is invalid (ESME_RINVMSGID=0x0000000C) at send.pl line 28. 

 #!/usr/bin/perl #use strict; #use warnings; use Net::SMPP; my $host = 'iphost'; my $port = 2345; my $smpp = Net::SMPP->new_transmitter( $host, port => $port, system_id => 'username', password => 'pass', ) or die; $resp_pdu = $smpp->submit_sm( destination_addr => '+44206064379', short_message => 'test message' ) or die; die "Response indicated error: " . $resp_pdu->explain_status() if $resp_pdu->status; $msg_id = $resp_pdu->{message_id}; $resp_pdu = $smpp->query_sm(message_id => $msg_id) or die; die "Response indicated error: " . $resp_pdu->explain_status() if $resp_pdu->status; print "Message state is $resp_pdu->{message_state}\n"; $resp_pdu = $smpp->replace_sm( message_id => $msg_id, short_message => 'another test' ) or die; die "Response indicated error: " . $resp_pdu->explain_status() if $resp_pdu->status; $resp_pdu = $smpp->cancel_sm(message_id => $msg_id) or die; die "Response indicated error: " . $resp_pdu->explain_status() if $resp_pdu->status; 
+4
source share
1 answer

If you try to send a message, you succeed. A message is sent using the submit_sm method.

The first line displays the result of query_sm, which returns the status of the message. State 2 corresponds to the DELIVERED status (from the SMPP v3.4 specification). This means that the SMSC delivered the message to the mobile device.

The error is generated by the replace_sm method. The replace_sm method will only replace the message that is still in the SMSC, that is, still awaiting delivery. If the message has already been delivered, the SMSC returns an error in the response PDU. The same applies to the cancel_sm method. It only works with messages that are still waiting for delivery.

+3
source

Source: https://habr.com/ru/post/1338628/


All Articles