javamailを使用してzipファイルを含む添付ファイルを送信しようとしています。送信中しかし、それはjavamailでzipファイルを送信できません
com.sun.mail.smtp.SMTPSendFailedExceptionなどの例外がスローされます。その内容は、潜在的な552-5.7.0セキュリティ上の問題を提示しているため552-5.7.0このメッセージがブロックされました。
私はapplication/zip
としてMIMEコンテンツタイプを追加しましたが、以下
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
application/zip at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1167)
私のコードスニペットで直面:
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(message, "application/zip");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
File srcFile = new File(System.getProperty("user.dir")+ "/Reports/");
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(srcFile.getPath()+"/Report.zip");
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName("Report.zip");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
私は.zip拡張子を削除すると、それは.zipファイルで正常に動作しますが、ないし。
いつですか?最初のエラーは、メールサーバーがZIP添付ファイルを好まないことを示唆しているようです.2番目のエラーはまったく異なり、電子メールがサーバーに渡される前に発生します。どちらですか? –
@Mark Rotteveel:すべてのエラーは 'Transport.send(message);'にあります。 – biz00ka
しかし、あなたはどちらか一方を取るべきです。両方ではありません。 1つのエラーが発生した場合と他のエラーが発生した場合は、注意深く記述してください。 –