1

When I try to send an email in Java using this code, it gives an error. Been googling this for a long time and can't seem to find a solution. Many people say I need to add ("mail.smtp.starttls.enable", "true") to my props, but it's already there. We're using the latest Jar (javax.mail (1.5)

Code:

 Message message = getMessage(session);
   message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(user.getEmail()));
   message.setSubject(PROPERTIES_HELPER.getProperty("EMAIL_" + emailSuffix +    "_USER_SUBJECT"));
   message.setContent(constructEmail(emailSuffix, customer, user), "text/html");

   Transport transport = session.getTransport("smtp");
   transport.connect(HOST, PORT, USER, PASS);

   Transport.send(message);

Error:

530 5.7.0 Must issue a STARTTLS command first. s3sm4537628eeo.3 - gsmtp
kosa
  • 65,990
  • 13
  • 130
  • 167
michael
  • 33
  • 1
  • 3
  • have you checked out the oracle faq on accessing gmail with javamail? http://www.oracle.com/technetwork/java/faq-135477.html#gmail also someone else had this issue with 1.4 (http://stackoverflow.com/questions/386083/must-issue-a-starttls-command-first-sending-email-with-java-and-google-apps) you might make certain the current javamail is in your classpath and not an older version. – scrappedcola Oct 15 '13 at 15:53
  • Yeah I've read that and it all looks fine as far as Oracle is concerned. It's really strange... thanks for the reply though. – michael Oct 15 '13 at 15:55

0 Answers0