title: Configure SMTP host using YAML file in Spring boot
body: <p>I am trying to configure an SMTP host for my Spring boot application. </p>
  
  <p>I have this code in my <code>application-dev.yml</code> file:</p>
  
  <pre><code> mail:
      host: smtp.gmail.com
      port: 465
      username: myemail@gmail.com
      password: mypassword
  </code></pre>
  
  <p>However, when I am trying to send an email I get this exception:</p>
  
  <pre><code>Caused by: javax.mail.MessagingException: Could not connect to 
  SMTP host: smtp.gmail.com, 
  port: 465, response: -1
  </code></pre>
  
  <p>Also, I have generated this code with JHipster and I am not sure whether I should modify something else or this is enough to configure a SMTP host.</p>
  
  <p>After changing the port to 587, I am getting this:</p>
  
  <pre><code>org.springframework.mail.MailSendException: 
  Failed messages:    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue 
  a STARTTLS command first. jm6sm60863600wjb.27 - gsmtp
  </code></pre>