0

我在

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

根据答案,电子邮件是错误的。我的问题是,有没有关于如何处理这个问题的想法?
如问题所述,如果我尝试发送:

内容类型:text/rfc822-headers;
内容传输编码:8bit

代替

内容类型:text/rfc822-headers;内容传输编码:8bit

它会起作用的。

通过使用属性mail.mime.contenttypehandler我可以添加自己的类来清理 Content-Type 标头,但这可能是有风险的,因为完整的验证、正则表达式...等可能会带来比它解决的问题更多的问题。以前有人遇到过这个问题吗?怎么解决?

任何想法都会受到赞赏。

4

1 回答 1

1

根据文档,问题出在 Content-Type 参数结构上,ti 应该是:

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

我刚刚创建了一个类来修复它,但我仍然认为必须有一些更好的解决方案。如果有人发现它,请继续回答!:)

谢谢

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();
    }
于 2013-11-21T08:31:14.523 回答