0

I got a java class which is used to send SMS to a mobile by java web application. But I am not getting following terms, how can i get these?

      String username = "MySMSUsername";// how to know MySMSUsername?
      String password = "MyPassword";//how to know password?
      String smtphost = "MySMSHost.com";//how to know SMSHost?
      String compression = "My SMS Compression Information";
      String from = "mySMSUsername@MySMSHost.com";
      String to = "PhoneNumberToText@sms.MySMSHost.com";
      String body = "Hello SMS World!";

Full sorce code: How to send SMS using Java

Community
  • 1
  • 1
saroj
  • 643
  • 8
  • 14
  • 25

4 Answers4

1

for sending sms from your application (web/desktop) you need any of the following solutions 1. Write up code and atttach a GSM Device (Phone/Modem) 2. Buy an api and integrate the same into your application 3. Buy and Email2SMS api and then integrate

above code seems to be using any APi , so you can buy an api from any of the vendors , you may google for bulksms and you will find the api vendors in your area , gaze on a particular api based on your need and the commercials,

all the above mentioned detaisl will be provided by them.

Akash Yadav
  • 2,411
  • 20
  • 32
1

You are referring to the code that is just a sending an e-mail using java program.Not sending sms using java.

String username = "saroj"; for example
String password = "saroj123";
String smtphost = "your e-mail server host name"; you can IP address of the mail server
String compression = "this is the subject of your e-mail"; 
String from = "saroj@saroj.com";
String to = "yourfreind@abc.com";
String body = "This is the actual message content";

All these information are required while sending an e-mail using java, not to send SMS.In order to send a sms, you need to configure SMS gateways.

UVM
  • 9,776
  • 6
  • 41
  • 66
  • but how can i configure SMS gateways? please give me a link where i can find all these things, particularly SMS gateways – saroj Apr 09 '12 at 09:43
0

You must be using some SMS providers API if not then you can not get these information. SMS provider will provide you your subscription username=MySMSUsername,Password, url or api to call through web service, HTTP etc, From to and body will be provided by the user through web application.

Shehzad
  • 2,870
  • 17
  • 21
0

As stated before, you must use a provider. SMPP protocol requires a SMS gateway and there is no free SMS gateway (as I know). However, once you have found a SMS gateway like SmsGlobal (there are many providers), you can use Ogham library for example. The code to send SMS is easy to write (it automatically handles character encoding and message splitting). The real SMS is sent either using SMPP protocol (standard SMS protocol) or through a provider. You can even test your code locally with a SMPP server to check the result of your SMS before paying for real SMS sending.

package fr.sii.ogham.sample.standard.sms;

import java.util.Properties;

import fr.sii.ogham.core.builder.MessagingBuilder;
import fr.sii.ogham.core.exception.MessagingException;
import fr.sii.ogham.core.service.MessagingService;
import fr.sii.ogham.sms.message.Sms;

public class BasicSample {
    public static void main(String[] args) throws MessagingException {
        // [PREPARATION] Just do it once at startup of your application
        
        // configure properties (could be stored in a properties file or defined
        // in System properties)
        Properties properties = new Properties();
        properties.setProperty("ogham.sms.smpp.host", "<your server host given by the provider>");                                 // <1>
        properties.setProperty("ogham.sms.smpp.port", "<your server port given by the provider>");                                 // <2>
        properties.setProperty("ogham.sms.smpp.system-id", "<your server system ID given by the provider>");                       // <3>
        properties.setProperty("ogham.sms.smpp.password", "<your server password given by the provider>");                         // <4>
        properties.setProperty("ogham.sms.from.default-value", "<phone number to display for the sender>");  // <5>
        // Instantiate the messaging service using default behavior and
        // provided properties
        MessagingService service = MessagingBuilder.standard()                                               // <6>
                .environment()
                    .properties(properties)                                                                  // <7>
                    .and()
                .build();                                                                                    // <8>
        // [/PREPARATION]
        
        // [SEND A SMS]
        // send the sms using fluent API
        service.send(new Sms()                                                                               // <9>
                        .message().string("sms content")
                        .to("+33752962193"));
        // [/SEND A SMS]
    }
}

There are many other features and samples / spring samples.

creponutella
  • 173
  • 3
  • 6