title: Java MimeMessage email printing header info in body
body: <p>A code base I inherited is printing out some header info in the body of email. This is what is being printed:</p>
  
  <pre><code>Mime-Version: 1.0
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  </code></pre>
  
  <p>If I <code>message.writeTo(System.out);</code> right after creating the message, the above text will print out.</p>
  
  <p>Is there a properties file or something somewhere that specifies this stuff?</p>
  
  <p>It also looks like when the mail arrives the outgoing server has written proper/different header information for these three attributes.</p>
  
  <p>Any ideas for removing it?</p>
  
  <p>Also, here is the whole function:</p>
  
  <pre><code>private String sendConfirmationEmail (String to, String from, String subject, String body, boolean CCSender) {
    try
    {
      String smtpHost = Properties.smtp;      
      String fromAddress = from;
      String toAddress = to;
  
      Properties properties = System.getProperties();
      properties.put("mail.smtp.host", smtpHost);
  
      Session session = Session.getInstance(properties, null);
  
      MimeMessage message = new MimeMessage(session);
  
      message.setFrom(new InternetAddress(fromAddress));
      message.setRecipient(Message.RecipientType.TO,
              new InternetAddress(toAddress));
  
      message.setRecipient(Message.RecipientType.BCC,
              new InternetAddress(fromAddress));
  
      if (CCSender) {
        message.setRecipient(Message.RecipientType.CC,
                new InternetAddress(from));
      }
      message.setSubject(subject);
      message.setText(body);
  
      message.saveChanges();
  
      Transport.send(message);
      return "1:success";
    }
    catch(Exception e)
    {
      return "0:failure "+e.toString();
    }
  }
  </code></pre>