在使用Grails的mail plugin的时候发现一个很奇怪的问题:
邮件模板中有<%@ page contentType="text/html;charset=UTF-8" %>,则发出的是plain text,不是html; 而把它改成<%@ page contentType="text/html" %>,就发出html的邮件了。
查看源代码:
class MailMessageBuilder { private MailMessage message static PATH_TO_MAILVIEWS = "/WEB-INF/grails-app/views" static HTML_CONTENTTYPES = ['text/html', 'text/xhtml'] ... if (HTML_CONTENTTYPES.contains(t.metaInfo.contentType)) { html(out.toString()) // @todo Spring mail helper will not set correct mime type if we give it XHTML } else { text(out) } ...代码写得不够严谨啊
