Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. javax.mail.AuthenticationFailedException: 534-5.7.14
  2. <https://accounts.google.com/ContinueSignIn?
  3. sarp=1&scc=1&plt=AKgnsbu7f
  4. 534-5.7.14 Zt-
  5. ibTxZf1iCvRrx_zqZ2e0gyU7UDBdKNf3Skj3y1daBQ4lwKDtlbWjuZVSBdqqJvWssPG
  6. 534-5.7.14
  7. axQ9afV4DYvgwRA6V94E2JKjGlqxgk8V7wxG9-lgPZoqbzI4rgBIk8SjDYwFt06r7tzWjs
  8.  
  9. 534-5.7.14 gn4zN1UWm-
  10. _BhrTGzjP02vV710gi2NHsgX7efxMTbZSowI02n1DL31Qhf_ba5vvtN8mSkI
  11. 534-5.7.14 mutNhiGJSG0_sSI0ZAiblBGGfc1o> Please log in via your web browser and
  12. 534-5.7.14 then try again.
  13. 534-5.7.14 Learn more at
  14. 534 5.7.14 https://support.google.com/mail/answer/78754 vy6sm35491986pac.38 - gsmtp
  15.  
  16. at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)
  17. at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
  18. at javax.mail.Service.connect(Service.java:295)
  19. at javax.mail.Service.connect(Service.java:176)
  20.  
  21. package com.mkyong.common;
  22.  
  23. import java.util.Properties;
  24.  
  25. import javax.mail.Message;
  26. import javax.mail.MessagingException;
  27. import javax.mail.PasswordAuthentication;
  28. import javax.mail.Session;
  29. import javax.mail.Transport;
  30. import javax.mail.internet.InternetAddress;
  31. import javax.mail.internet.MimeMessage;
  32.  
  33. public class SendMailTLS {
  34.  
  35. public static void main(String[] args) {
  36.  
  37. final String username = "username@gmail.com";
  38. final String password = "password";
  39.  
  40. Properties props = new Properties();
  41. props.put("mail.smtp.auth", "true");
  42. props.put("mail.smtp.starttls.enable", "true");
  43. props.put("mail.smtp.host", "smtp.gmail.com");
  44. props.put("mail.smtp.port", "587");
  45.  
  46. Session session = Session.getInstance(props,
  47. new javax.mail.Authenticator() {
  48. protected PasswordAuthentication getPasswordAuthentication() {
  49. return new PasswordAuthentication(username, password);
  50. }
  51. });
  52.  
  53. try {
  54.  
  55. Message message = new MimeMessage(session);
  56. message.setFrom(new InternetAddress("from-email@gmail.com"));
  57. message.setRecipients(Message.RecipientType.TO,
  58. InternetAddress.parse("to-email@gmail.com"));
  59. message.setSubject("Testing Subject");
  60. message.setText("Dear Mail Crawler,"
  61. + "nn No spam to my email, please!");
  62.  
  63. Transport.send(message);
  64.  
  65. System.out.println("Done");
  66.  
  67. } catch (MessagingException e) {
  68. throw new RuntimeException(e);
  69. }
  70.  
  71. package com.mkyong.common;
  72.  
  73. import java.util.Properties;
  74. import javax.mail.Message;
  75. import javax.mail.MessagingException;
  76. import javax.mail.PasswordAuthentication;
  77. import javax.mail.Session;
  78. import javax.mail.Transport;
  79. import javax.mail.internet.InternetAddress;
  80. import javax.mail.internet.MimeMessage;
  81.  
  82. public class SendMailSSL {
  83. public static void main(String[] args) {
  84. Properties props = new Properties();
  85. props.put("mail.smtp.host", "smtp.gmail.com");
  86. props.put("mail.smtp.socketFactory.port", "465");
  87. props.put("mail.smtp.socketFactory.class",
  88. "javax.net.ssl.SSLSocketFactory");
  89. props.put("mail.smtp.auth", "true");
  90. props.put("mail.smtp.port", "465");
  91.  
  92. Session session = Session.getDefaultInstance(props,
  93. new javax.mail.Authenticator() {
  94. protected PasswordAuthentication getPasswordAuthentication() {
  95. return new PasswordAuthentication("username","password");
  96. }
  97. });
  98.  
  99. try {
  100.  
  101. Message message = new MimeMessage(session);
  102. message.setFrom(new InternetAddress("from@no-spam.com"));
  103. message.setRecipients(Message.RecipientType.TO,
  104. InternetAddress.parse("to@no-spam.com"));
  105. message.setSubject("Testing Subject");
  106. message.setText("Dear Mail Crawler," +
  107. "nn No spam to my email, please!");
  108.  
  109. Transport.send(message);
  110.  
  111. System.out.println("Done");
  112.  
  113. } catch (MessagingException e) {
  114. throw new RuntimeException(e);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement