Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javax.mail.AuthenticationFailedException: 534-5.7.14
- <https://accounts.google.com/ContinueSignIn?
- sarp=1&scc=1&plt=AKgnsbu7f
- 534-5.7.14 Zt-
- ibTxZf1iCvRrx_zqZ2e0gyU7UDBdKNf3Skj3y1daBQ4lwKDtlbWjuZVSBdqqJvWssPG
- 534-5.7.14
- axQ9afV4DYvgwRA6V94E2JKjGlqxgk8V7wxG9-lgPZoqbzI4rgBIk8SjDYwFt06r7tzWjs
- 534-5.7.14 gn4zN1UWm-
- _BhrTGzjP02vV710gi2NHsgX7efxMTbZSowI02n1DL31Qhf_ba5vvtN8mSkI
- 534-5.7.14 mutNhiGJSG0_sSI0ZAiblBGGfc1o> Please log in via your web browser and
- 534-5.7.14 then try again.
- 534-5.7.14 Learn more at
- 534 5.7.14 https://support.google.com/mail/answer/78754 vy6sm35491986pac.38 - gsmtp
- at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)
- at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
- at javax.mail.Service.connect(Service.java:295)
- at javax.mail.Service.connect(Service.java:176)
- package com.mkyong.common;
- import java.util.Properties;
- import javax.mail.Message;
- import javax.mail.MessagingException;
- import javax.mail.PasswordAuthentication;
- import javax.mail.Session;
- import javax.mail.Transport;
- import javax.mail.internet.InternetAddress;
- import javax.mail.internet.MimeMessage;
- public class SendMailTLS {
- public static void main(String[] args) {
- final String username = "username@gmail.com";
- final String password = "password";
- Properties props = new Properties();
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.starttls.enable", "true");
- props.put("mail.smtp.host", "smtp.gmail.com");
- props.put("mail.smtp.port", "587");
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }
- });
- try {
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress("from-email@gmail.com"));
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse("to-email@gmail.com"));
- message.setSubject("Testing Subject");
- message.setText("Dear Mail Crawler,"
- + "nn No spam to my email, please!");
- Transport.send(message);
- System.out.println("Done");
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
- package com.mkyong.common;
- import java.util.Properties;
- import javax.mail.Message;
- import javax.mail.MessagingException;
- import javax.mail.PasswordAuthentication;
- import javax.mail.Session;
- import javax.mail.Transport;
- import javax.mail.internet.InternetAddress;
- import javax.mail.internet.MimeMessage;
- public class SendMailSSL {
- public static void main(String[] args) {
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.gmail.com");
- props.put("mail.smtp.socketFactory.port", "465");
- props.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory");
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.port", "465");
- Session session = Session.getDefaultInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication("username","password");
- }
- });
- try {
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress("from@no-spam.com"));
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse("to@no-spam.com"));
- message.setSubject("Testing Subject");
- message.setText("Dear Mail Crawler," +
- "nn No spam to my email, please!");
- Transport.send(message);
- System.out.println("Done");
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement