Sending SMS from JAVA

HI,

I need to send SMS to client from my application. For this i followed sending SMS from email by using below code.

import java.io.;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail.
;
import javax.mail.internet.;
import javax.activation.
;

public class SMTPSend {

public SMTPSend() {
}

public void msgsend() {
String username = “username”;
String password = “password”;
String smtphost = “smtp.gmail.com”;
String compression = “My SMS Compression Information”;
String from = “username@gmail.com”;
String to = “mobilenumber@serviceprovider.com”;
String body = “Hello SMS World!”;
Transport myTransport = null;

try {
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = System.getProperties();
props.put(“mail.transport.protocol”, “smtp”);
props.put(“mail.smtp.starttls.enable”,“true”);
props.put(“mail.smtp.host”, smtphost);
props.put(“mail.smtp.auth”, “true”);
//props.put(“mail.smtp.port”,“465”);
//props.put(“mail.smtp.starttls.required”, “true”);
Session mailSession = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(compression);
msg.setText(body);
msg.setSentDate(new Date());

myTransport = mailSession.getTransport(“smtp”);
myTransport.connect(smtphost, username, password);
msg.saveChanges();
myTransport.sendMessage(msg, msg.getAllRecipients());
myTransport.close();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String argv) {
SMTPSend smtpSend = new SMTPSend();
smtpSend.msgsend();
}
}

It compiled successfully, but while running this code getting below exception:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. s29sm10871689wak.14

What to do to resolve this?
Sorry for the long post.
Please help me to complete this, it is very urgent.

Thanks&Regards
Jagan.

According to this, there’s a rather simple solution