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