Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Properties prop =new Properties();
  2. prop.put("mail.smtp.auth","true");
  3. prop.put("mail.smtp.starttls.enable","true");
  4. prop.put("mail.smtp.host","smtp.gmail.com");
  5. prop.put("mail.smtp.port","587");
  6. prop.put("mail.smtp.ssl.trust", "*");
  7.  
  8. final String username = "andrzej.kokosza13";
  9. final String password = "asd1fgh2jkl3";
  10. final String fromEmail= "andrzej.kokosza13@gmail.com";
  11. final String toEmail = "katdon@st.amu.edu.pl";
  12. final String subject = "Spam";
  13. final String text = "";
  14. Session session = Session.getDefaultInstance(prop, new Authenticator(){
  15. @Override
  16. protected PasswordAuthentication getPasswordAuthentication(){
  17. return new PasswordAuthentication(username,password);
  18. }
  19. });
  20. for(int i=1; i<=10;i++) {
  21. try {
  22. Message message = new MimeMessage(session);
  23. message.setFrom(new InternetAddress(fromEmail));
  24. message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail));
  25. message.setSubject(subject);
  26. message.setText(text);
  27. Transport.send(message);
  28. } catch (Exception e) {
  29. e.printStackTrace();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement