Results 1 to 3 of 3
  1. #1
    snehil2009 is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default Exception in sending mail....plz help

    <%@page import="java.util.*"%>
    <%@page import="javax.mail.*"%>
    <%@page import="javax.mail.internet.*"%>

    Properties props = new Properties();
    props.put("", "");

    Session s = Session.getInstance(props, null);
    MimeMessage message = new MimeMessage(s);
    InternetAddress from = new InternetAddress(" ");

    InternetAddress to = new InternetAddress(" ");
    message.addRecipient(Message.RecipientType.TO, to);
    message.setSubject("Test from JavaMail.");
    message.setText("Hello from JavaMail!");


    <p align="center">
    A Message has been sent. <br>
    Check your inbox.

    <p align="center">
    <a href="sendmail.jsp">Click here to send another!</a>

    i tried to send mail using above code....i am getting the following exception

    javax.servlet.ServletException: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first.

    plz help how to resolve this

  2. #2
    hemant086 is offline Member
    Join Date
    Jan 2010
    Rep Power


    The error may have come due to the absence of the given email addresses,
    like,; I am not sure but do check them,
    if possible give an existing email ids.....

  3. #3
    FON is offline Senior Member
    Join Date
    Dec 2009
    Belgrade, Serbia
    Rep Power


    Security and authorization problems.

    First of all use debug:
    Java Code:
    so you can see in your console what is going on.

    You have TLS - Transport Layer Security problem and auth problem too.

    TLS ( "...STARTTLS command first"):
    You need to add to your props:

    Java Code:


    Java Code:
     props.put("mail.smtp.auth", "true");
    You need to provide your gmail account username and password
    to auth yourself. You do that in special class that has to inherit
    javax.mail.Authenticator, and then just put instance of your class in Session

    Java Code:
     Session session = Session.getDefaultInstance(props, myAythenticator);
    when you finish please show us your solution

    good luck !

Similar Threads

  1. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 05:37 AM
  2. Sending a Mail
    By haiforhussain in forum Advanced Java
    Replies: 7
    Last Post: 07-30-2008, 12:28 AM
  3. Replies: 2
    Last Post: 05-05-2008, 06:01 AM
  4. Sending a mail with the local mail program
    By thedude in forum Advanced Java
    Replies: 2
    Last Post: 07-23-2007, 12:19 PM
  5. Sending mail Using JAVAMAIL
    By peiceonly in forum Advanced Java
    Replies: 3
    Last Post: 07-19-2007, 02:11 PM

Posting Permissions

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