MimeMessage exception exceptions when sending SimpleMailMessage

I am trying to send a very simple email with org.springframework.mail.javamail.JavaMailSenderImpl. Below is the code:

SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(request.getCustomerEmail()); mailMessage.setSubject("someSubject"); mailMessage.setFrom(" vincent@myDomain.com "); mailSender.send(mailMessage); 

This is the exception I get:

 Caused by: org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: No MimeMessage content at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:459) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:307) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:296) 

I really don't understand why this is happening.

Any idea?

+5
source share
1 answer

After a couple of hours of struggle, I discovered that this is all, because the mail I create does not have text!

If I add this line, then it works like a charm:

 mailMessage.setText("blabla"); 

I was really confused by the message "No MimeMessage content". Does anyone agree that the message may be more informative, or is it just me? Does this mean that we can’t send an email only with a question and without content?

+6
source

Source: https://habr.com/ru/post/1233241/


All Articles