title: How do I test the JavaMailSender of Spring
body: <p>I have a service that has injected the JavaMailSender.
  My service configures it and sends a mail.
  I'd like to intercept the raw mail to ensure the information is the correct. I'd like to do that in a JUnit.</p>
  
  <p>How would you guys do that?</p>
  
  <pre><code>@Service
  public class MyServiceImpl {
  
      @Autowired
      private JavaMailSender _mailSender;
  
      public void sendMail(String to, String body, String subject){
          ...
          _mailSender.something
          ...
      }
  }
  </code></pre>