use an inner class to prevent the call of updateMessageID
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
import javax.crypto.KeyGenerator;
import javax.mail.Header;
public class SMIMEGenerator
{
private static Map BASE_CIPHER_NAMES = new HashMap();
- private final static Properties dummyProps = new Properties();
- private final static Session dummySession;
static
{
BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.AES128_CBC, "AES");
BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.AES192_CBC, "AES");
BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.AES256_CBC, "AES");
-
- dummyProps.put("mail.from", "dummy@example.com");
- dummySession = Session.getDefaultInstance(dummyProps);
}
protected boolean useBase64 = true;
@@ -76,7 +70,14 @@ protected MimeBodyPart makeContentBodyPart(
//
try
{
- MimeMessage msg = new MimeMessage(dummySession);
+ MimeMessage msg = new MimeMessage((Session) null) {
+ // avoid the call of updateMessageID to prevent
+ // DNS issues when trying to evaluate the local host's name
+ @Override
+ protected void updateMessageID() throws MessagingException {
+ // do nothing
+ }
+ };
Enumeration e = content.getAllHeaders();
