title: JavaMail - Sender Address rejected: Access Denied
body: <p>Ok, I don't know what else to do. This code worked perfectly fine a week ago when I wrote and tested it. Then I embedded it into my program and realised I kept getting exceptions. Everything seems normal. The sender address is legit. The recipient addresses I used to test it are legit. What is wrong? I'm so frustrated:</p>
  
  <pre><code>private String outgoingMailServer = "smtp.mail.yahoo.com";
  
  boolean debug = true;
  
              //set the host outgoing mail smtp server.
              Properties properties = new Properties();
              properties.put("mail.smtp.host", outgoingMailServer);
              properties.put("mail.smtp.auth", "true");
  
              Authenticator authenticator = new SMTPAuthentication();
              Session session = Session.getDefaultInstance(properties, authenticator);
  
              session.setDebug(debug);
  
              //create a message session
              Message msg = new MimeMessage(session);
  
              //set the addresses, to and from
              InternetAddress fromAddress;
              fromAddress = new InternetAddress(emailFromAddress);
              msg.setFrom(fromAddress);
  
              //since mail can be sent to more than one recipient, create loop
              //to add all addresses into InternetAddress, addressTo.
              //InternetAddress[] toAddress = new InternetAddress[recipients.length];
              InternetAddress[] toAddress = new InternetAddress[recipients.size()];
              for (int i = 0; i &lt; recipients.size(); i++) {
                  toAddress[i] = new InternetAddress(recipients.get(i));
              }
              msg.setRecipients(Message.RecipientType.TO, toAddress);
  
              //set the subject and content type
              msg.setSubject(emailSubject);
              msg.setContent(actualMessage, "text/html; charset=utf-8");
  
              //send the email
              Transport.send(msg);
  </code></pre>
  
  <p>The exception is thus:</p>
  
  <pre><code>javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
      com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 &lt;blank@yahoo.com&gt;: Sender address rejected: Access denied
  
      at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1835)
      at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1098)
      at javax.mail.Transport.send0(Transport.java:195)
      at javax.mail.Transport.send(Transport.java:124)
      at internalLogicEngine.LogicEngine.sendReminder(LogicEngine.java:4282)
      at testPackage.Test.main(Test.java:169)
  Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 &lt;blank@yahoo.com&gt;: Sender address rejected: Access denied
  
      at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1733)
      ... 5 more
  </code></pre>
  
  <p>Any help would be most appreciated. Thanks!</p>