Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Spring框架的空邮件_Java_Spring_Maven_Email - Fatal编程技术网

Java 使用Spring框架的空邮件

Java 使用Spring框架的空邮件,java,spring,maven,email,Java,Spring,Maven,Email,我试图使用Spring框架发送一封简单的电子邮件,但我有一个非常奇怪的问题:在Junit测试用例中,一切都正常工作,但是当我从应用程序调用该函数时,邮件有正确的收件人,但它是空的!(在Gmail中我可以看到一个“没有名字”的附件) 以下是我的配置: MailerServiceImpl @Override public void sendMail(String recipient, String content, String attachmentFileName, byte[]

我试图使用Spring框架发送一封简单的电子邮件,但我有一个非常奇怪的问题:在Junit测试用例中,一切都正常工作,但是当我从应用程序调用该函数时,邮件有正确的收件人,但它是空的!(在Gmail中我可以看到一个“没有名字”的附件)

以下是我的配置:

MailerServiceImpl

@Override
public void sendMail(String recipient, String content,
        String attachmentFileName, byte[] attachment) throws Exception {

    MimeMessage message = mailSender.createMimeMessage();


    MimeMessageHelper helper = new MimeMessageHelper(message, true);
    helper.setFrom(simpleMailMessage.getFrom());
    helper.setTo(recipient);
    helper.setSubject(simpleMailMessage.getSubject());
    helper.setText(String.format(simpleMailMessage.getText(), content));

    if (attachment != null && attachmentFileName != null) {
        helper.addAttachment(attachmentFileName, new ByteArrayResource(
                attachment));
    }
    logger.log(Level.INFO, "MimeMessageHelper Created");
    try {
        mailSender.send(message);
        logger.log(Level.INFO, "Email sent to: "
                + message.getAllRecipients().toString());
    } catch (MailException e) {
        logger.log(Level.SEVERE, "Error while sending mail", e);
        throw new EipException("Errore email", e);
    }

}
private JavaMailSender mailSender;

public void setMailSender(JavaMailSender mailSender) {
    this.mailSender = mailSender;
}

private SimpleMailMessage simpleMailMessage;

public void setSimpleMailMessage(SimpleMailMessage simpleMailMessage) {
    this.simpleMailMessage = simpleMailMessage;
}
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="192.168.209.208" />
    <property name="port" value="25" />
    <property name="username" value="xxx" />
    <property name="password" value="xxx" />
    <property name="javaMailProperties">
        <props>
            <prop key="mail.smtp.auth">false</prop>
            <prop key="mail.smtp.starttls.enable">false</prop>
        </props>
    </property>
</bean>
<bean id="simpleMailMessage" class="org.springframework.mail.SimpleMailMessage">
    <property name="from" value="info@test.com" />
    <property name="to" value="" />
    <property name="subject" value="Info" />
    <property name="text">
        <value><![CDATA[%s]]></value>
    </property>
</bean>
applicationContext.xml

@Override
public void sendMail(String recipient, String content,
        String attachmentFileName, byte[] attachment) throws Exception {

    MimeMessage message = mailSender.createMimeMessage();


    MimeMessageHelper helper = new MimeMessageHelper(message, true);
    helper.setFrom(simpleMailMessage.getFrom());
    helper.setTo(recipient);
    helper.setSubject(simpleMailMessage.getSubject());
    helper.setText(String.format(simpleMailMessage.getText(), content));

    if (attachment != null && attachmentFileName != null) {
        helper.addAttachment(attachmentFileName, new ByteArrayResource(
                attachment));
    }
    logger.log(Level.INFO, "MimeMessageHelper Created");
    try {
        mailSender.send(message);
        logger.log(Level.INFO, "Email sent to: "
                + message.getAllRecipients().toString());
    } catch (MailException e) {
        logger.log(Level.SEVERE, "Error while sending mail", e);
        throw new EipException("Errore email", e);
    }

}
private JavaMailSender mailSender;

public void setMailSender(JavaMailSender mailSender) {
    this.mailSender = mailSender;
}

private SimpleMailMessage simpleMailMessage;

public void setSimpleMailMessage(SimpleMailMessage simpleMailMessage) {
    this.simpleMailMessage = simpleMailMessage;
}
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="192.168.209.208" />
    <property name="port" value="25" />
    <property name="username" value="xxx" />
    <property name="password" value="xxx" />
    <property name="javaMailProperties">
        <props>
            <prop key="mail.smtp.auth">false</prop>
            <prop key="mail.smtp.starttls.enable">false</prop>
        </props>
    </property>
</bean>
<bean id="simpleMailMessage" class="org.springframework.mail.SimpleMailMessage">
    <property name="from" value="info@test.com" />
    <property name="to" value="" />
    <property name="subject" value="Info" />
    <property name="text">
        <value><![CDATA[%s]]></value>
    </property>
</bean>
}

在Junit测试用例中,我加载了相同的spring上下文,webapp中唯一的区别是数据库配置(通过Tomcat中的JNDI)。。。但这不应该成为问题

我想到了Maven中的库冲突(我读到了与geronimo邮件的冲突)。。。但似乎效果不错 有什么建议吗

再见 卡洛

编辑: 这是两封已发送电子邮件的两个日志。(前者是空白的,后者是正确的)

空白

DEBUG SMTP: trying to connect to host "192.168.209.208", port 25,     isSSL false
220 hostname ESMTP Postfix (Debian/GNU)
DEBUG SMTP: connected to host "192.168.209.208", port: 25

EHLO MASLNN112
250-hostname
250-PIPELINING 
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "10240000"
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<xxx@example.com>
250 2.1.0 Ok
RCPT TO:<xxx@example.com>
250 2.1.5 Ok
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   xxx@example.com
DATA
354 End data with <CR><LF>.<CR><LF>
Date: Tue, 16 Feb 2016 11:49:21 +0100 (CET)
From: xxx@example.com
To: xxx@example.com
Message-ID: <839107267.2.1455619761727.JavaMail.carlo@MASLNN112>
Subject: Integrazione Enel - Comunicazione
MIME-Version: 1.0
Content-Type: multipart/mixed; 
boundary="----=_Part_0_1452882369.1455619761619"

.
250 2.0.0 Ok: queued as AB2047A5251
QUIT
221 2.0.0 Bye
DEBUG SMTP:尝试连接到主机“192.168.209.208”,端口25,isSSL false
220主机名ESMTP后缀(Debian/GNU)
调试SMTP:已连接到主机“192.168.209.208”,端口:25
EHLO MASLN112
250主机名
250-流水线
250码10240000
250-VRFY
250-ETRN
250-STARTTLS
250-增强状态码
250-8比特
250 DSN
调试SMTP:找到扩展名“管道”,arg“”
调试SMTP:找到扩展名“SIZE”,arg“10240000”
调试SMTP:找到扩展名“VRFY”,参数“”
调试SMTP:找到扩展名“ETRN”,参数“”
调试SMTP:找到扩展名“STARTTLS”,arg“”
调试SMTP:找到扩展名“ENHANCEDSTATUSCODES”,arg“”
调试SMTP:找到扩展名“8BITMIME”,参数“”
调试SMTP:找到扩展名“DSN”,参数“”
调试SMTP:use8bit false
邮寄地址:
250 2.1.0正常
RCPT至:
250 2.1.5正常
调试SMTP:已验证的地址
调试SMTP:xxx@example.com
资料
354使用结束数据。
日期:2016年2月16日星期二11:49:21+0100(CET)
发件人:xxx@example.com
致:xxx@example.com
消息ID:
主题:Enel-Comuniczione集成
MIME版本:1.0
内容类型:多部分/混合;
boundary=“---=\u Part\u 0\u 1452882369.1455619761619”
.
250 2.0.0正常:作为AB2047A5251排队
退出
221 2.0.0再见
正确

DEBUG SMTP: trying to connect to host "192.168.209.208", port 25, isSSL false
220 hostname ESMTP Postfix (Debian/GNU)
DEBUG SMTP: connected to host "192.168.209.208", port: 25

EHLO MASLNN112
250-hostname
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "10240000"
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<xxx@example.com>
250 2.1.0 Ok
RCPT TO:<xxx@example.com>
250 2.1.5 Ok
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   xxx@example.com
DATA
354 End data with <CR><LF>.<CR><LF>
Date: Tue, 16 Feb 2016 11:45:51 +0100 (CET)
From: xxx@example.com
To: xxx@example.com
Message-ID: <563330706.2.1455619551945.JavaMail.carlo@MASLNN112>
Subject: Integrazione Enel - Comunicazione
MIME-Version: 1.0
Content-Type: multipart/mixed; 
boundary="----=_Part_0_967231573.1455619550687"

------=_Part_0_967231573.1455619550687
Content-Type: multipart/related; 
boundary="----=_Part_1_309604348.1455619550701"

------=_Part_1_309604348.1455619550701
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

test mail.
------=_Part_1_309604348.1455619550701--

------=_Part_0_967231573.1455619550687--
.
250 2.0.0 Ok: queued as DFC317A5251
QUIT
221 2.0.0 Bye
DEBUG SMTP:尝试连接到主机“192.168.209.208”,端口25,isSSL false
220主机名ESMTP后缀(Debian/GNU)
调试SMTP:已连接到主机“192.168.209.208”,端口:25
EHLO MASLN112
250主机名
250-流水线
250码10240000
250-VRFY
250-ETRN
250-STARTTLS
250-增强状态码
250-8比特
250 DSN
调试SMTP:找到扩展名“管道”,arg“”
调试SMTP:找到扩展名“SIZE”,arg“10240000”
调试SMTP:找到扩展名“VRFY”,参数“”
调试SMTP:找到扩展名“ETRN”,参数“”
调试SMTP:找到扩展名“STARTTLS”,arg“”
调试SMTP:找到扩展名“ENHANCEDSTATUSCODES”,arg“”
调试SMTP:找到扩展名“8BITMIME”,参数“”
调试SMTP:找到扩展名“DSN”,参数“”
调试SMTP:use8bit false
邮寄地址:
250 2.1.0正常
RCPT至:
250 2.1.5正常
调试SMTP:已验证的地址
调试SMTP:xxx@example.com
资料
354使用结束数据。
日期:2016年2月16日星期二11:45:51+0100(CET)
发件人:xxx@example.com
致:xxx@example.com
消息ID:
主题:Enel-Comuniczione集成
MIME版本:1.0
内容类型:多部分/混合;
boundary=“---=\u Part\u 0\u 967231573.1455619550687”
------=_部分_0_967231573.1455619550687
内容类型:多部分/相关;
边界=“---=”第1部分\U 30964348.1455619550701”
------=第1部分\u 30964348.1455619550701
内容类型:文本/纯文本;字符集=美国ascii码
内容传输编码:7bit
测试邮件。
------=第1部分\u 30964348.1455619550701--
------=_部分_0_967231573.1455619550687--
.
250 2.0.0正常:作为DFC317A5251排队
退出
221 2.0.0再见
编辑2:

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.arpav</groupId>
<artifactId>eip2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Enel Integrator Process 2</name>

<properties>
    <java.version>1.7</java.version>
    <drools.version>6.2.0.Final</drools.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <hibernate.version>4.2.6.Final</hibernate.version>
    <hibernate.core.version>4.2.6.Final</hibernate.core.version>
    <hibernate.validator.version>4.2.0.Final</hibernate.validator.version>
    <slf4j.version>1.6.4</slf4j.version>
    <jboss.javaee.version>1.0.0.Final</jboss.javaee.version>
    <logback.version>1.0.9</logback.version>
    <h2.version>1.3.161</h2.version>
    <btm.version>2.1.4</btm.version>
    <junit.version>4.10</junit.version>
    <spring.version>3.2.12.RELEASE</spring.version>
    <sitemesh.version>3.0.0</sitemesh.version>
    <log4j.version>1.2.17</log4j.version>
    <jackson.version>1.9.9</jackson.version>
</properties>


<dependencies>


    <!-- test dependencies -->

    <!-- <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-api</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency> -->

    <!-- Junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>org.javassist</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jboss-logging</artifactId>
                <groupId>org.jboss.logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.core.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>org.javassist</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jboss-logging</artifactId>
                <groupId>org.jboss.logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>${h2.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- <dependency>
        <groupId>org.codehaus.btm</groupId>
        <artifactId>btm</artifactId>
        <version>${btm.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-api</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency> -->

    <!-- Spring -->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency> -->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.version}</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <!-- Servlet & Jsp -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>

    <!-- Jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Jackson JSON Mapper -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <!-- Servlet Spec -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <!-- Sitemesh -->
    <dependency>
        <groupId>org.sitemesh</groupId>
        <artifactId>sitemesh</artifactId>
        <version>${sitemesh.version}</version>
    </dependency>

    <!-- Log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
    </dependency>

    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901-1.jdbc4</version>
    </dependency>

    <!-- Hibernate -->

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>${hibernate.validator.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-api</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.apache.openejb</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0-4</version>
        <scope>provided</scope>
    </dependency>

    <!-- Richieste http -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5</version>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.2</version>
    </dependency>

    <!-- SDEE -->
    <dependency>
        <groupId>it.enel</groupId>
        <artifactId>SDEE</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <!-- Invio emails -->

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>

</dependencies>
<repositories>
    <repository>
        <id>springsource-milestones</id>
        <name>SpringSource Milestones Proxy</name>
        <url>https://oss.sonatype.org/content/repositories/springsource-milestones</url>
    </repository>

    <!-- <repository> <id>jboss-public-repository-group</id> <name>JBoss Public 
        Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
        <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> 
        <snapshots> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </snapshots> 
        </repository> -->
</repositories>

<build>
    <finalName>eip2</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

4.0.0
it.arpav
eip2
0.0.1-快照
战争
Enel积分器过程2
1.7
6.2.0.1最终版本
UTF-8
4.2.6.最终版本
4.2.6.最终版本
4.2.0.4最终版本
1.6.4
1.0.0.1决赛
1.0.9
1.3.161
2.1.4
4.10
3.2.12.发布
3.0.0
1.2.17
1.9.9
朱尼特
朱尼特
${junit.version}
测试
org.springframework
弹簧试验
${spring.version}
测试
org.slf4j
slf4j api
1.7.5
测试
org.hibernate
休眠实体管理器
${hibernate.version}
编译
javassist
org.javassist
jboss日志
org.jboss.logging
org.hibernate
冬眠核心
${hibernate.core.version}
测试
javassist
org.javassist
jboss日志
org.jboss.logging
com.h2数据库
氢
${h2.version}
测试
org.springframework
弹簧芯
${spring.version}
公用记录
公用记录
org.springframework
SpringWebMVC
${spring.version}
org.springframework
春季甲虫
${spring.version}
罐子
编译
org.springframework
弹簧网
${spring.version}
org.springframework
弹簧试验
${spring.version}
罐子
测试
org.springframework
spring上下文支持
${spring.version}
javax.servlet
jsp api
2
假如
javax.servlet
jstl
1.2
org.codehaus.jackson
杰克逊地图绘制者
${jackson.version}
javax.servlet
servlet api
2.4
假如
javax.servlet.jsp
jsp api
2.1
假如
org.sit
/**
 * This implementation creates a SmartMimeMessage, holding the specified
 * default encoding and default FileTypeMap. This special defaults-carrying
 * message will be autodetected by {@link MimeMessageHelper}, which will use
 * the carried encoding and FileTypeMap unless explicitly overridden.
 * @see #setDefaultEncoding
 * @see #setDefaultFileTypeMap
 */
public MimeMessage createMimeMessage() {
    return new SmartMimeMessage(getSession(), getDefaultEncoding(), getDefaultFileTypeMap());
}
protected String getDefaultEncoding(MimeMessage mimeMessage) {
    if (mimeMessage instanceof SmartMimeMessage) {
        return ((SmartMimeMessage) mimeMessage).getDefaultEncoding();
    }
    return null;
}
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
        <scope>provided</scope> <------------ here
    </dependency>