Я пытался прикрепить файл почтового индекса с помощью JavaMail и получаю ошибку ниже:Issue прикрепление почтовый файл в JavaMail
«com.sun.mail.smtp.SMTPSendFailedException: 552-5.7.0 Это сообщение было заблокировано потому что его содержание представляет собой потенциальную проблему безопасности. Обратитесь к http://support.google.com/mail/bin/answe 552-5.7.0 r.py?answer=6590, чтобы просмотреть содержимое и содержимое вложений 552 5.7.0. vb7sm60966875pbc.13 - gsmtp "
Прикрепление документа или xls не имеет проблем. Я даже считаю, что привязка zip-файла ничем не отличается от любого другого файла. Пожалуйста, дайте мне знать, в чем проблема.
Я также предоставил код при необходимости.
public class SendMail {
@Test
public static void sendFileEmail()
{
// Recipient's email ID needs to be mentioned.
String to = "*****@gmail.com";
// Sender's email ID needs to be mentioned
String from = "****@gmail.com";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
properties.put("mail.debug", "false");
// Get the default Session object.
Session session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("*****@gmail.com","****");
}
});
try {
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO, new InternetAddress(
to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("This is message body");
// Create a multipar message
Multipart multipart = new MimeMultipart();
// Set text message part
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
String filename = "XSLTReports.zip";
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
// Send the complete message parts
message.setContent(multipart);
// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
Я считаю, что проблема связана с содержанием zip-файла. Я изменил zip-файл, и он работает нормально. Спасибо за ваш ответ ! – Siv