Advertisement
Guest User

Untitled

a guest
Jul 10th, 2018
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import java.security.Security;
  2. import java.util.Properties;
  3.  
  4. import javax.mail.Authenticator;
  5. import javax.mail.Message;
  6. import javax.mail.MessagingException;
  7. import javax.mail.PasswordAuthentication;
  8. import javax.mail.Session;
  9. import javax.mail.Transport;
  10. import javax.mail.internet.InternetAddress;
  11. import javax.mail.internet.MimeMessage;
  12.  
  13. public class Main {
  14.  
  15. public static void main(String[] args) {
  16. String username = "noreply@gtanksonline.com";
  17. String password = "ATXzMtSM";
  18.  
  19. Properties props = new Properties();
  20. props.put("mail.smtp.host", "gtanksonline.com");
  21. /* props.put("mail.smtp.socketFactory.port", "465");
  22. props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
  23. props.put("mail.smtp.socketFactory.fallback", "false");
  24. props.put("mail.smtp.auth", "true");*/
  25. props.put("mail.smtp.port", "25");
  26. props.put("mail.smtp.ssl.trust", "*");
  27.  
  28. Session session = Session.getInstance(props, new Authenticator() {
  29. protected PasswordAuthentication getPasswordAuthentication() {
  30. return new PasswordAuthentication(username, password);
  31. }
  32. });
  33.  
  34. try {
  35. Message message = new MimeMessage(session);
  36.  
  37. message.setFrom(new InternetAddress(username));
  38. message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("scpacker19@gmail.com"));
  39. message.setSubject("TEST");
  40. message.setText("gtanks online");
  41.  
  42.  
  43. Transport.send(message);
  44. } catch (MessagingException e) {
  45. throw new RuntimeException(e);
  46. }
  47.  
  48.  
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement