title: Spring boot sending emails using Thymeleaf as template - configuration does not work
body: <p>I have a working WebApp based on Spring Boot (newest 1.1.5.RELEASE) and Thymeleaf.<br/>
  Now I would like to add functionality to send emails and use Thymeleaf as templating engine.
  <br/><br/>
  In pom.xml I add:<br/></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.integration&lt;/groupId&gt;
      &lt;artifactId&gt;spring-integration-mail&lt;/artifactId&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;javax.mail&lt;/groupId&gt;
      &lt;artifactId&gt;mail&lt;/artifactId&gt;
      &lt;version&gt;1.4.7&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.activation&lt;/groupId&gt;
      &lt;artifactId&gt;activation&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Following this tutorial: <a href="http://www.thymeleaf.org/doc/articles/springmail.html" rel="nofollow noreferrer">http://www.thymeleaf.org/doc/articles/springmail.html</a>
  <br/>
  I got complete (no XML) Java configuration like that:</p>
  
  <pre><code>@Configuration
  public ThymeleafReplaceConfigurator {
    @Bean 
     public JavaMailSender getJavaMailSenderImpl(){
          JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
  
          Properties props = new Properties();
          /* some properties here */
  
          javaMailSender.setJavaMailProperties(props);
  
      return javaMailSender;
      }
  
      @Bean
      public ClassLoaderTemplateResolver emailTemplateResolver(){
          ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
          emailTemplateResolver.setPrefix("/mails/");
          emailTemplateResolver.setSuffix(".html");
          emailTemplateResolver.setTemplateMode("HTML5");
          emailTemplateResolver.setCharacterEncoding("UTF-8");
          emailTemplateResolver.setOrder(1);
  
          return emailTemplateResolver;
      }
  
      @Bean
      public ServletContextTemplateResolver defaultWebTemplateResolver(){
          ServletContextTemplateResolver webTemplateResolver = new ServletContextTemplateResolver();
          webTemplateResolver.setPrefix("/templates/");
          webTemplateResolver.setSuffix(".html");
          webTemplateResolver.setTemplateMode("HTML5");
          webTemplateResolver.setCharacterEncoding("UTF-8");
          webTemplateResolver.setOrder(2);
  
          return webTemplateResolver;
      }
  
      @Bean
      public SpringTemplateEngine templateEngine(){
      SpringTemplateEngine templateEngine = new SpringTemplateEngine();
      templateEngine.setTemplateResolver(emailTemplateResolver());
      templateEngine.setTemplateResolver(defaultWebTemplateResolver());
      return templateEngine;
      }
  
      @Bean
      public ThymeleafViewResolver thymeleafViewResolver() {
          ThymeleafViewResolver thymeleafViewResolver = new ThymeleafViewResolver();
  
          thymeleafViewResolver.setTemplateEngine(templateEngine());
          thymeleafViewResolver.setCharacterEncoding("UTF-8");
  
          return thymeleafViewResolver;
      }
  }
  </code></pre>
  
  <p>Folder and files tree is like:</p>
  
  <pre><code>src
    main
      resources
        templates
          login.html
          error.html
        mails
          exampleMail.html
  </code></pre>
  
  <p>But it does not work. Application starts correctly but accessing pages (which works without this configuration) causes exception like:</p>
  
  <p>Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "login", template might not exist or might not be accessible by any of the configured Template Resolvers<br/><br/>
  I tried to put different prefixes into webTemplateResolver.setPrefix but without success.
  <br/>
  Also I have noticed reported bug in earlier version of Thymeleaf causing that but looks like it was fixed and I have newer version.<br/><br/>
  <strong>Does anyone see the mistake in this configuration?</strong></p>