Mailer(String protocolType, String host, Integer port, String username, String password) throws Exception {
this.username = username;
this.password = password;
this.props = new Properties();
this.props.setProperty("mail.store.protocol", protocolType);
this.session = Session.getInstance(props);
store = session.getStore();
store.connect(host, port, username, password);
}
Mailer mailer = null;
try {
mailer = new Mailer("imaps", "smtp.gmail.com", 587, "hsdvyfgyfg@gmail.com", "ghghghfgf");
} catch (Exception e) {
e.printStackTrace();
}
try {
mailer.setSMTP("smtp.gmail.com", 587, true);
Asked
Active
Viewed 23 times
0

Lothar
- 5,323
- 1
- 11
- 27
-
This link will be usefull for what you are trying. https://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/ . Looks like the configuration imaps and smtp.gmail.com is not correct. – Francisco Valle Feb 08 '18 at 18:15
-
See the [Gmail instructions in the JavaMail FAQ](https://javaee.github.io/javamail/FAQ#gmail). – Bill Shannon Feb 08 '18 at 21:36
-
Possible duplicate of [Unrecognized SSL message, plaintext connection? Exception](https://stackoverflow.com/questions/6532273/unrecognized-ssl-message-plaintext-connection-exception) – user207421 Feb 08 '18 at 22:04