title: Having troubles sending emails from spring boot application
body: <p>I have been trying to send email via spring boot and i cant seem to succeed. I am been using javamail api for a long time now but want to use springboot with spring mail.</p>
  
  <pre><code>public class SendMail {
  
      @Autowired
      private JavaMailSender javaMailSender;
  
      public void sendingMail(String to, String subject, String body) {
          SimpleMailMessage message = new SimpleMailMessage();
          message.setTo(to);
          message.setSubject(subject);
          message.setText(body);
          javaMailSender.send(message);
      }
  
  }
  </code></pre>
  
  <p>and here is my mailer</p>
  
  <pre><code>@Controller
  public class ExamPle {
  
      @Autowired
      private SendMail  sendMail;
  
      @RequestMapping("/he")
      public String homePage() {
          sendMail.sendingMail("bobobush007@gmail.com", "Welcome George", "Sample Message here");
          return "Sent";
          }
  }
  </code></pre>
  
  <p>I already have sprint-boot-starter-mail in my pom file but i keep getting this error message. I have even watched youtube videos of tutorials on how to do this and yet it doesn't work. I am using Spring Tool Suite Version: 3.9.0.RELEASE.</p>
  
  <p>Properties file</p>
  
  <pre><code>spring.mail.host=smtp.gmail.com
  spring.mail.username=my-email-address
  spring.mail.password=my-password
  spring.mail.port=587
  spring.mail.properties.mail.smtp.auth=true
  spring.mail.properties.mail.smtp.starttls.enable=true
  spring.mail.defaultEncoding=UTF-8
  </code></pre>
  
  <blockquote>
    <p>2017-09-14 05:25:57.811  INFO 12576 --- [           main]
    com.example.demo.EmaildemoApplication    : Starting
    EmaildemoApplication on Georges-MacBook-Pro.local with PID 12576
    (started by georgetebo in /Users/georgetebo/STS Projects/Emaildemo)
    2017-09-14 05:25:57.814  INFO 12576 --- [           main]
    com.example.demo.EmaildemoApplication    : No active profile set,
    falling back to default profiles: default 2017-09-14 05:25:57.845 
    INFO 12576 --- [           main]
    ationConfigEmbeddedWebApplicationContext : Refreshing
    org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3d3fcdb0:
    startup date [Thu Sep 14 05:25:57 WAT 2017]; root of context hierarchy
    2017-09-14 05:25:58.652  INFO 12576 --- [           main]
    s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with
    port(s): 8080 (http) 2017-09-14 05:25:58.662  INFO 12576 --- [<br>
    main] o.apache.catalina.core.StandardService   : Starting service
    [Tomcat] 2017-09-14 05:25:58.662  INFO 12576 --- [           main]
    org.apache.catalina.core.StandardEngine  : Starting Servlet Engine:
    Apache Tomcat/8.5.20 2017-09-14 05:25:58.714  INFO 12576 ---
    [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       :
    Initializing Spring embedded WebApplicationContext 2017-09-14
    05:25:58.714  INFO 12576 --- [ost-startStop-1]
    o.s.web.context.ContextLoader            : Root WebApplicationContext:
    initialization completed in 871 ms 2017-09-14 05:25:58.821  INFO 12576
    --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/] 2017-09-14 05:25:58.823 
    INFO 12576 --- [ost-startStop-1]
    o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter:
    'characterEncodingFilter' to: [/<em>] 2017-09-14 05:25:58.824  INFO 12576
    --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/</em>] 2017-09-14
    05:25:58.824  INFO 12576 --- [ost-startStop-1]
    o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter:
    'httpPutFormContentFilter' to: [/<em>] 2017-09-14 05:25:58.824  INFO
    12576 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   :
    Mapping filter: 'requestContextFilter' to: [/</em>] 2017-09-14
    05:25:58.848  WARN 12576 --- [           main]
    ationConfigEmbeddedWebApplicationContext : Exception encountered
    during context initialization - cancelling refresh attempt:
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'examPle': Unsatisfied dependency
    expressed through field 'sendMail'; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    qualifying bean of type 'com.example.demo.SendMail' available:
    expected at least 1 bean which qualifies as autowire candidate.
    Dependency annotations:
    {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    2017-09-14 05:25:58.850  INFO 12576 --- [           main]
    o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
    2017-09-14 05:25:58.861  INFO 12576 --- [           main]
    utoConfigurationReportLoggingInitializer : </p>
    
    <p>Error starting ApplicationContext. To display the auto-configuration
    report re-run your application with 'debug' enabled. 2017-09-14
    05:25:58.927 ERROR 12576 --- [           main]
    o.s.b.d.LoggingFailureAnalysisReporter   : </p>
    
    <p>*************************** APPLICATION FAILED TO START</p>
    
    <hr>
    
    <p>Description:</p>
    
    <p>Field sendMail in com.example.demo.ExamPle required a bean of type
    'com.example.demo.SendMail' that could not be found.</p>
    
    <p>Action:</p>
    
    <p>Consider defining a bean of type 'com.example.demo.SendMail' in your
    configuration.</p>
  </blockquote>
  
  <p>This is my Pom file</p>
  
  <p>
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;com.mailsender&lt;/groupId&gt;
  &lt;artifactId&gt;MailSender&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;MailSender&lt;/name&gt;
  &lt;description&gt;ZemoPoint for Spring Boot&lt;/description&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.5.6.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-mail&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have uninstalled my jdk as well as STS and installed new copies.Now i get this error</p>