title: com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required (Java Mail)
body: <p>So i'm trying to get Java Mail to work and because other answers I've seen of this site are not working, I have to assume somethings have changed in the past year or so. So I apoligies if this question seems like a DUPLICATE I can't figure out why it is not working. The following is my code:</p>
  
  <pre><code>try{
          Properties property = new Properties();
          property.setProperty("mail.smtp.host", "smtp.gmail.com");
          property.setProperty("mail.smtp.starttls.enable", "true");
          //property.setProperty("mail.smpt.port", "25");
          property.setProperty("mail.smtp.user", "myEmail@gmail.com");
          property.setProperty("mail.smtp.auth", "true");
  
          System.out.println("Mail Check 1");
  
          Session session = Session.getDefaultInstance(property);
          MimeMessage message = new MimeMessage(session);
          message.setFrom(new InternetAddress("myEmail@gmail.com"));
          message.addRecipient(Message.RecipientType.TO, new InternetAddress("myEmail@gmail.com"));
  
          System.out.println("Mail Check 2");
  
          message.setSubject("Oil Error Report");
          message.setText(emailMessage);
  
          System.out.println("Mail Check 3");
  
          Transport transport = session.getTransport("smtps");
          transport.connect("smtp.gmail.com",465,"myEmail@gmail.com","myPassword");
          transport.sendMessage(message, message.getAllRecipients());
          transport.close();
  
          System.out.println("Mail Sent");
      }catch(Exception ex){
          System.out.println("Mail fail");
          System.out.println(ex);
      }
  </code></pre>
  
  <p>I get up to Mail Check 3 then I get the following exception:</p>
  
  <pre><code>com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
  530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 u3sm10254140ioi.27 - gsmtp
  </code></pre>
  
  <p>Which doesn't make sense because I have mail.smtp.auth set to true. I have looked at past answers and I have tried to get it to work for while before posting. I'm assuming it's something simple.. Any help would be much appreciated! Thanks!</p>