在电子邮件中发送多部分文件时出错。
org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: /tmp/tomcat.8099.7871695435416015654/work/Tomcat/localhost/ROOT/upload_090af3f0_4090_48f5_b9fa_4724022873bb_00000000.tmp (No such file or directory)
我正在使用ubuntu服务器运行JavaSpringBoot(2.4.0)jar文件。这是我的密码
@Async
public void sendMessageWithAttachment(
EmailMapper emailMapper,
List<MultipartFile> files) throws MessagingException {
// ...
if (emailMapper != null) {
List<Subscriber> subscribers = kaleService.getAllSubscribers();
for (int index = 0; index < subscribers.size(); index++) {
MimeMessage message = emailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setTo(subscribers.get(index).getEmail());
helper.setFrom(kale_email_from);
helper.setSubject(emailMapper.getSubject());
helper.setText(emailMapper.getDescription());
if(files != null ) {
for (int indexOfFiles = 0; indexOfFiles < files.size(); indexOfFiles++) {
helper.addAttachment(files.get(indexOfFiles).getOriginalFilename(), files.get(indexOfFiles));
}
}
System.out.println("Sending email to : " + subscribers.get(index).getEmail());
emailSender.send(message);
}
}
}
在没有多部分文件的情况下发送电子邮件工作正常
spring启动版本2.4.0 ubuntu服务器
暂无答案!
目前还没有任何答案,快来回答吧!