title: Got bad greeting from SMTP host: smtp.yandex.ru, port: 465, response: [EOF]] with root cause Yandex
body: <p>I use brand new spring boot project with next Maven dependency</p>
  <pre><code> &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;
  </code></pre>
  <p>Implementation of method</p>
  <pre><code> @Autowired
  JavaMailSender emailSender;
  
  @GetMapping(&quot;/send&quot;)
  public String send() {
      SimpleMailMessage message = new SimpleMailMessage();
      message.setFrom(&quot;some-name@domain.com&quot;);
      message.setTo(&quot;toReceiver@gmail.com&quot;);
      message.setSubject(null);
      message.setText(&quot;Hello World&quot;);
      emailSender.send(message);
      return &quot;success send email &quot; + now();
  }
  </code></pre>
  <p>application.yml</p>
  <pre><code>host: smtp.yandex.ru
  username: some-name@domain.io
  password: password
  port: 465
  </code></pre>
  <p>And receive the next exception</p>
  <pre><code>2020-08-03 23:02:35.102 ERROR 21615 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.yandex.com, port: 465, response: [EOF]. 
  </code></pre>
  <p><code>Failed messages: javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.yandex.com, port: 465, response: [EOF]; message exceptions (1) are: Failed message 1: javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.yandex.com, port: 465, response: [EOF]] with root cause</code></p>
  <p>But the same code works perfectly with <a href="https://mailtrap.io" rel="noreferrer">Mailtrap</a> service</p>
  <p>According to this <a href="http://settings.su/yandex" rel="noreferrer">link</a>  I used not secure 25 port
  After which I received the next exception</p>
  <pre><code>Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.yandex.ru, 25; timeout -1;
  </code></pre>
  <p>587 port =</p>
  <pre><code>Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: [EOF];
  </code></pre>
  <p>I guess a problem with SSL</p>
  <p>Similar <a href="https://stackoverflow.com/questions/12743846/unable-to-send-an-email-using-smtp-getting-javax-mail-messagingexception-could">issue</a></p>