Guest User

Untitled

a guest
Oct 12th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public static void main(String[] args) {
  2. // Recipient's email ID needs to be mentioned.
  3. String to = "destinationemail@gmail.com";
  4.  
  5. // Sender's email ID needs to be mentioned
  6. String from = "fromemail@gmail.com";
  7. final String username = "manishaspatil";//change accordingly
  8. final String password = "******";//change accordingly
  9.  
  10. // Assuming you are sending email through relay.jangosmtp.net
  11. String host = "relay.jangosmtp.net";
  12.  
  13. Properties props = new Properties();
  14. props.put("mail.smtp.auth", "true");
  15. props.put("mail.smtp.starttls.enable", "true");
  16. props.put("mail.smtp.host", host);
  17. props.put("mail.smtp.port", "25");
  18.  
  19. // Get the Session object.
  20. Session session = Session.getInstance(props,
  21. new javax.mail.Authenticator() {
  22. protected PasswordAuthentication getPasswordAuthentication() {
  23. return new PasswordAuthentication(username, password);
  24. }
  25. });
Add Comment
Please, Sign In to add comment