How to Send SMS in Java using Third Party SMS API’s

How to Send SMS in Java using Third Party SMS API’s : Almost all the bulk SMS providers are sharing the SMS Apis as well to send the SMS from our java/php/any other programming languages. When you are planning to send bulk sms to your customers/users about any offers then you may need to buy bulk SMS from any bulksms provider in india.

I have bought bulksms from shlrtechnosoft, I really enjoyed too with their service.



1. Buy the bulk SMS from any bulksms providers. (If you don’t find anyone, comment to this post to help you).
2. Ensure you got userid, password and senderid from them.



Steps in overview:

  • Create a contacts map with number and name.
  • Iterate the contacts map and send the numbers to the sendSMSThrougAPI() one by one to send the SMS.
  • Jsoup is used here to connect and trigger the SMS using the third party Api.
  • Character count restrictions/sending the name of the contact/different contact groups can be created/customized with this program.


Send SMS using Thirdparty APIs – Java Source Code:

Change the below things before running this program.

  • YOUR_SMS_API_URL in sendSMSThrougAPI().

package in.javadomain;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class SendSMS {

private static String inviteMsg = " Best Online shopping website in india. \n Couponzcorner.";
HashMap<String, String> contactsMap = new HashMap<String, String>();
String thirdPartyAPIUserID = "YOUR_SMS_API_USERID";
String thirdPartyAPIPassword = "YOUR_SMS_API_PASSWORD";
String thirdPartyAPISenderID = "YOUR_SMS_API_SENDERID";
// Don't forget to change the url of the sms api in the sendSMSThrougAPI() method.

public static void main(String[] args) {
System.out.println("Sending SMS Started");
SendSMS ssms = new SendSMS();
System.out.println("Sending SMS Completed");

public void getContacts(){
// Enable this if loop if you want to restrict the message length to be less than 160
if (inviteMsg.length() <= 159) {
// Testing Contacts

// Create other contact groups and add it to commonIteration here to send
// commonIteration(this.getRelations());

public void commonIteration(HashMap<String, String> contactGrp) {
Set<Map.Entry<String, String>> cmnSet = contactGrp.entrySet();
for (Map.Entry<String, String> mp : cmnSet) {
// if you want to send the name from the map dynamically then use mp.getValue() to get it.
SendSMS sendSMS = new SendSMS();
boolean response = sendSMS.sendSMSThrougAPI(mp.getKey(),
System.out.println(mp.getKey() + "==>" + response);

private boolean sendSMSThrougAPI(String number, String msg) {
boolean isSMSSent = false;
msg = URLEncoder.encode(msg);
try {
String URL = ""+thirdPartyAPIUserID+"&password="+thirdPartyAPIPassword+"&sender="+thirdPartyAPISenderID+"&mobileno="+ number + "&msg=" + msg;
Document apiResponse = Jsoup.connect(URL).timeout(0).get();
String responseIS = apiResponse.toString();
if (responseIS.contains("Success")) {
isSMSSent = true;
} else {
isSMSSent = false;
} catch (Exception e) {
System.out.println("Issue with jsoup" + e.getStackTrace());
return isSMSSent;
public HashMap<String, String> getFriends() {
return contactsMap;


Console Output:

Sending SMS Started
Sending SMS Completed




Feel free to share any thoughts/comments in the below comments section.

 1,747 total views,  1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.