I tried to send an e-mail using GNU JavaMail 1.1.1 in combination with
GNU Activation 1.1 with this simple code:
Session session = Session.getInstance(new Properties());
MimeMessage mm = new MimeMessage(session);
mm.setSender(new InternetAddress(sender));
mm.setRecipient(RecipientType.TO, new InternetAddress(recipient));
mm.setSubject(subject);
mm.setText(message);
Transport transport = session.getTransport("smtp");
transport.connect(host_, port_, "", "");
Address[] recipients = { new InternetAddress(recipient) };
transport.sendMessage(mm, recipients);
This led to the following exception:
javax.mail.SendFailedException: no object DCH for MIME type text/
plain; charset=UTF-8
at gnu.mail.providers.smtp.SMTPTransport.sendMessage
(SMTPTransport.java:520)
Tracking down the problem I found this code in
javax.activation.ObjectDataContentHandler:
public void writeTo(Object object, String mimeType, OutputStream
out)
throws IOException
{
if (dch != null)
{
dch.writeTo(object, mimeType, out);
}
throw new UnsupportedDataTypeException("no object DCH for MIME
type " + mimeType);
}
This method seems to have a bug because the exception gets thrown even
if dch is not null.