title: Java Mail writeTo and read back gives Illegal semicolon error
body: <p>I am using java to get a mail message and persist that message to a file. When I go to read the file back in I am getting an javax.mail.internet.AddressException</p>
  
  <p>Below is the code I use to write the message</p>
  
  <pre><code>Properties mailProps = System.getProperties();
  mailProps.setProperty("mail.store.protocol", "imaps");
  Session session = null;
  Folder inbox = null;
  Store store = null;
  Message[] messages = null;
  
  try {
      session = Session.getDefaultInstance(mailProps, null);
      store = session.getStore("imaps");
  
      store.connect(config.getMailHost(), config.getMailUserId(), config.getMailPasswd());
  
      inbox = store.getFolder("inbox");
      inbox.open(Folder.READ_WRITE); // Folder.READ_ONLY
      logger.info("Total Messages found on Host: &lt;{}&gt;", inbox.getMessageCount());
      logger.info("Total Unread Messages on Host: &lt;{}&gt;", inbox.getUnreadMessageCount());
  
      messages = inbox.getMessages();
  
      for (Message currMessage : messages) {
  
          File mailFile = buildMailFileName();
          currMessage.writeTo(new FileOutputStream(mailFile));
      }
  }
  </code></pre>
  
  <p>I can see the file is created and contains the following line:</p>
  
  <blockquote>
    <p>To: Name@domain.com;</p>
  </blockquote>
  
  <p>When I go to read the file back in I get the following error:</p>
  
  <p><strong>javax.mail.internet.AddressException: Illegal semicolon, not in group in string 'Name@domain</strong>.</p>
  
  <p>Here is the code I use to read the file:</p>
  
  <pre><code>Session session = Session.getDefaultInstance(mailProps, null);
  FileInputStream fis = new FileInputStream(mailFile);
  MimeMessage mime = new MimeMessage(null, fis);
  Address[] addresses = mime.getRecipients(Message.RecipientType.TO);
  </code></pre>