Friday, 21 September 2012

How can send email from a Java app using Gmail?

You need to Set Properties as Below :
String host = "smtp.gmail.com";
String from = "user name";//email address
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", "asdfgh");
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");

No comments:

Post a Comment