How to send sms using java
i have done the following codes:
public class Sms {
public Sms() {
}
public void msgsend() {
String username = "guoxiang";
String password = "*******";
String smtphost = "ipipi.com";
String compression = "on";
String from = "guoxiang@gmail.com";
String to = "92706121";
String body = "Hello SMS World!";
Transport myTransport = null;
try {
Properties props = System.getProperties();
props.put("mail.smtp.auth", "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) {
Sms smtpSend = new Sms();
smtpSend.msgsend();
}
}
i got the error
javax.mail.AuthenticationFailedException: 535 Authentication Failed
at com.sun.mail.smtp.SMTPTransport$Authenticator.auth enticate(SMTPTransport.java:648)
please help me