Results 1 to 7 of 7
  1. #1
    jaganmodulla is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default 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?
    Please help me to complete this, it is very urgent.

    Thanks&Regards
    Jagan.

  2. #2
    francojava1 is offline Member
    Join Date
    Sep 2010
    Posts
    26
    Rep Power
    0

    Default Sending SMS from Java

    Okay dear Client, Iam francojava1, who is going to create a Java Server Pages to thoses codes program that are running on you
    computer. Please give me some days. Also, let me be clear would you like to send me the zip folder program compiled to do this fix first.

    Sincerely, Thanks

  3. #3
    jaganmodulla is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default Please find the attached zip folder

    Hi,

    Thanks for your response.
    Please find the attached zip file and do the needful to me.

    Regards
    Jagan.
    Attached Files Attached Files

  4. #4
    francojava1 is offline Member
    Join Date
    Sep 2010
    Posts
    26
    Rep Power
    0

    Default

    Hello, Mr. Jaga. I have received his original.zip, but I think that you need to remove this exception there my friend . I got specific codes about the MessageRemovedException, and it will fix this problem . Please give two days more Okay. Thanks..

  5. #5
    francojava1 is offline Member
    Join Date
    Sep 2010
    Posts
    26
    Rep Power
    0

    Default Sending SMS from Java

    Hello Jaga, Iam francojava1, who sent this program compiled very well
    please jaga looks attachments in the folder javax, there is the class
    SMTPSend . Tell me if you have the " Hello World SMS " .

    Thanks Iam a student of college
    on Business Programming.
    Attached Files Attached Files

  6. #6
    francojava1 is offline Member
    Join Date
    Sep 2010
    Posts
    26
    Rep Power
    0

    Default

    Hello Jagan, Iam francojava1, who have already fixed his Exception Problem Java . Please look my attachments folder javax, and jaga tell me, do you have the Hello World SMS HTML in correct format .


    Thanks
    Last edited by francojava1; 09-28-2010 at 04:15 PM.

  7. #7
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    gmail SMTP requires an SSL thats why you get Must issue a STARTTLS command first. try using your ISP SMTP.

Similar Threads

  1. Java Mail sending
    By jazz2k8 in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2011, 07:08 AM
  2. Sending SMS from java program
    By bonjovi4u in forum Networking
    Replies: 0
    Last Post: 06-21-2010, 07:56 PM
  3. Java Packet sending UDP
    By g123456 in forum Advanced Java
    Replies: 16
    Last Post: 06-10-2010, 04:38 PM
  4. Sending SMS with Java
    By btln701 in forum Advanced Java
    Replies: 10
    Last Post: 02-20-2010, 02:42 PM
  5. Sending SMS with Java-URGENT
    By Robert_85 in forum Advanced Java
    Replies: 1
    Last Post: 04-06-2009, 04:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •