title: How to Sign Javamail with DKIM
body: <p>Is there a library or a way to do this without an external library? I am using apache james as my mail server and currently send email like this:</p>
  
  <pre><code>public void sendMessage(String to, String subject, String content) {
      MimeMessage message = new MimeMessage(session);
      try {
          message.addRecipients(Message.RecipientType.TO, to);
          message.setFrom(new InternetAddress(from));
          message.setSubject(subject);
          message.setContent(content, "text/html; charset=utf-8");
          Transport.send(message);
      } catch (MessagingException e) {
          e.printStackTrace();
      }       
  }
  </code></pre>
  
  <p>But i'd like to sign the email with DKIM before hand. I understand I need to implement DKIM signing into the james server and plan on use jDKIM to do this, I also understand I need to create the keys using something like www.port25.com, but how do I actually sign the email in java before I send it out?</p>