Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public class Main {
  2. public static void main(String[] args){
  3. final String username = "labtime@mail.labtime.ufg.br";
  4. final String password = "Lt28xm37o1";
  5.  
  6. Properties props = new Properties();
  7. props.put("mail.smtp.auth", true);
  8. props.put("mail.smtp.starttls.enable", true);
  9. props.put("mail.smtp.ssl.trust", "192.168.1.28");
  10. props.put("mail.smtp.host", "192.168.1.28");
  11. props.put("mail.smtp.port", "10587");
  12.  
  13. Session session = Session.getInstance(props,
  14. new javax.mail.Authenticator() {
  15. protected PasswordAuthentication getPasswordAuthentication() {
  16. return new PasswordAuthentication(username, password);
  17. }
  18. });
  19.  
  20. try {
  21.  
  22. Message message = new MimeMessage(session);
  23. message.setFrom(new InternetAddress("labtime@mail.labtime.ufg.br"));
  24. message.setRecipients(Message.RecipientType.TO,
  25. InternetAddress.parse("rhandyrafhael@gmail.com"));
  26. message.setSubject("Dear Testing Subject");
  27. message.setText("Dear Mail Crawler,"
  28. + "\n\n No spam to my email, please!");
  29. Transport.send(message);
  30. System.out.println("Done");
  31.  
  32. } catch (MessagingException e) {
  33. throw new RuntimeException(e);
  34. }
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement