Domanda

I have found my very same error in

https://forums.oracle.com/thread/2449918

According to the answer, the email is just wrong. My question is, is there any idea about how to handle the problem?
As in the question says, if I try to send:

Content-Type: text/rfc822-headers;
Content-Transfer-Encoding: 8bit

Instead of

Content-Type: text/rfc822-headers; Content-Transfer-Encoding: 8bit

It will work.

By using the property mail.mime.contenttypehandler I could add my own class to clean up the Content-Type header, but it might be risky, since a complete validation, regex... etc could bring more problems than it solves. Has anybody faced this problem before? How would it be soved?

Any idea would be apreciated.

È stato utile?

Soluzione

According to the documentation, the problem is the Content-Type parameter structure, ti should be:

Content-Type: text/rfc822-headers; Content-Transfer-Encoding= 8bit

I have just created a class to fix it, but still I think there must be some better solution. If someone finds it, please keep answering! :)

Thanks

public static String cleanContentType(String contentType){
        StringBuilder cleanedContentType = new StringBuilder();
        if(contentType.contains(";")){   //It contains paramenter
            cleanedContentType.append(contentType.split(";")[0]).append("; ");
            if(contentType.split(";").length > 1){
                for(int i = 1; i < contentType.split(";").length ; i++){
                    cleanedContentType.append(contentType.split(";")[i].replace(":", "=")).append("; ");
                }
            }
        } else{
            return contentType;
        }

        return cleanedContentType.toString();
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top