我的Java应用程序使用Spring JavaMail发送消息。
<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage"/>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${email.smtp}" />
<property name="username" value="${email.user}" />
<property name="password" value="${email.password}" />
<property name="port" value="${email.port}" />
<property name="javaMailProperties">
<props>
<prop key="mail.transport.protocol">smtp</prop>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.debug">true</prop>
<prop key="mail.mime.multipart.allowempty">true</prop>
</props>
</property>
</bean>
运行以下代码,消息将正确发送到“To address”。但是,“CC”和“BCC”被忽略了。
MimeMessage message = ((JavaMailSender)mailSender).createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, email.isMultipart(), "UTF-8");
helper.setFrom(new InternetAddress(email.getFrom(), personal, "UTF-8"));
helper.setTo(email.getTo().split(","));
helper.setSubject(email.getSubject());
helper.setText(email.getText(), email.isHtml());
if (email.getCc() != null && email.getCc().isEmpty()) {
helper.setCc(email.getCc().split(","));
}
if (email.getBcc() != null && email.getBcc().isEmpty()) {
helper.setBcc(email.getBcc().split(","));
}
if (!emailHidden) {
((JavaMailSender)mailSender).send(message);
}
任何人都可以帮我解决这个问题吗?非常感谢!
答案 0 :(得分:0)
难怪他们被忽略了:你刚刚在这两行中输了一个拼写错误:
# file pkg@1821417@27528.dstream.Z
pkg@1821417@27528.dstream.Z: html document
应该是:
email.getCc().isEmpty()
!email.getCc().isEmpty()
相同。