Announcement Announcement Module
Collapse
No announcement yet.
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. 5sm505 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. 5sm505

    When i try to send mail to a gmail account i am getting following.

    Code:
    	javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. 5sm5058134qwg.40
    Thanks.

  • #2
    kumarsrs,

    You need to set some properties for your SMTP connection. You have no code or bean definitions, so I can't even guess how you're sending the email, but you'll need to set the following properties for the javax.mail stuff.

    Code:
    mail.smtp.starttls.enable=true
    mail.smtp.starttls.required=true
    Hope that helps.

    Comment


    • #3
      Hi, Thanks for the reply.

      I tried with SimpleMailMessage, i can receive the mail.

      Code:
      		SimpleMailMessage msg = new SimpleMailMessage(this.mailMessage);
      		System.out.println("Simple Mail Message" + msg.toString());
      		Date date = new Date();
      		msg.setSentDate(date);
      		msg.setSubject("test");
      
      		msg.setFrom("[email protected]");
      		msg.setText("this is a test");
      msg.setTo("[email protected]");
      mailSender.send(msg);
      but fails when i try to use
      Code:
      		msg.setText("<html><body><h1>welcome</h1><body></html");
      then i came to know about MimeMessageHelper tried the following

      Code:
      JavaMailSenderImpl sender = new JavaMailSenderImpl();
      		sender.setHost("smtp.gmail.com");
      		MimeMessage msg = sender.createMimeMessage();
      		MimeMessageHelper helper = new MimeMessageHelper(msg,true);
      		Properties props = new Properties();
      		props.put("mail.smtp.starttls.enable","true");
      		props.put( "mail.smtp.auth", "true" );
      		props.put("mail.smtp.port","425");
      
      		Session session = Session.getDefaultInstance(props,null); 
      
      		helper.setTo("[email protected]");
      		helper.setSubject("mysubject");
      		helper.setText("<html><body><h1>hi welcome</h1><body></html", true);
      		sender.send(msg);
      I am getting the error
      Code:
      javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. 6sm5311994qwd.38

      Comment


      • #4
        Added the following
        Code:
        	     props.put("mail.smtp.starttls.enable", "true"); // added this line  
        	     props.put("mail.smtp.host", host);  
        	     props.put("mail.smtp.port", "587");  
        	     props.put("mail.smtp.auth", "true"); 
        	     props.put("mail.smtp.starttls.required", "true"); // added this line

        Comment


        • #5
          Resolution:

          Hi,

          Set the following tags. It will work

          props.put("mail.smtp.user","Your username");
          props.put("mail.smtp.host", "smtp.gmail.com");
          props.put("mail.smtp.port", "25");
          props.put("mail.debug", "true");
          props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.starttls.enable","true");
          props.put("mail.smtp.EnableSSL.enable","true");

          props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.setProperty("mail.smtp.socketFactory.fallbac k", "false");
          props.setProperty("mail.smtp.port", "465");
          props.setProperty("mail.smtp.socketFactory.port", "465");

          Thanks,
          Last edited by Rupal kathiriya; Apr 21st, 2012, 07:06 AM.

          Comment

          Working...
          X