---
title: How to send SMS in Java with bulksms API | 100% best for beginners
url: https://kensoftph.com/send-sms-in-java/
date: 2020-09-28T12:18:00+00:00
modified: 2022-02-07T05:04:10+00:00
lang: en_US
---

# How to send SMS in Java with bulksms API | 100% best for beginners

## How to send SMS in Java

Well, SMS is a text messaging service component of most telephone, Internet, and mobile device systems. In Java, we can programmatically send SMS in Java with the BulkSMS API. Simply create an account at [https://www.bulksms.com/account/#!/registration](https://www.bulksms.com/account/#!/registration). Once you've successfully created an account at bulksms.com then go to Java and paste this code.

```
import java.net.*;
import java.io.*;

public class SendSms {

static public void main(String[] args) {
try {
// Construct data
String data = "";
/*
* Note the suggested encoding for certain parameters, notably
* the username, password and especially the message. ISO-8859-1
* is essentially the character set that we use for message bodies,
* with a few exceptions for e.g. Greek characters. For a full list,
* see: http://developer.bulksms.com/eapi/sub...
*/
data += "username=" + URLEncoder.encode("myusername", "ISO-8859-1");
data += "&password=" + URLEncoder.encode("xxxxxx", "ISO-8859-1");
data += "&message=" + URLEncoder.encode("This is a test", "ISO-8859-1");
data += "&want_report=1";
data += "&msisdn=44123123123";

// Send data
// Please see the FAQ regarding HTTPS (port 443) and HTTP (port 80/5567)
URL url = new URL("https://bulksms.vsms.net/eapi/submiss...");

URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
// Print the response output...
System.out.println(line);
}
wr.close();
rd.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} 
```

Run it and enjoy it!

[![send sms in java](https://kensoftph.com/wp-content/uploads/2020/09/sms-scaled.jpg)](https://kensoftph.com/wp-content/uploads/2020/09/sms-scaled.jpg)

## YouTube Video

https://youtu.be/L0F_nvA1x7E
