title: Unable to send mail using Spring Framework
body: <p>By sending an email I got the following exception:</p>
  
  <pre><code>org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. b10sm22671312wmi.34 - gsmtp
  </code></pre>
  
  <p>Here is the code that I'm using for sending email:</p>
  
  <pre><code>MailRequest mailRequest = new MailRequest();
  mailRequest.setSubject(messageByLocale.getMessage("mail.subject.forgetpassword"));
  mailRequest.setTemplateName(messageByLocale.getMessage("mail.template.forgetpassword"));
  mailRequest.setToEmail(tbNstyleloyalty.getEmail());
  Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
  map.put("tbNstyleloyalty", tbNstyleloyalty);
  mailingConfig.sendEmail(mailRequest, map);
  </code></pre>
  
  <p>And my <code>sendEmail</code> method is:</p>
  
  <pre><code>@Async
  public void sendEmail(MailRequest mailRequest, Map&lt;String, Object&gt; model) {
      MimeMessagePreparator preparator = new MimeMessagePreparator() 
      {
          @Override
          public void prepare(MimeMessage mimeMessage) throws Exception {
                  MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
                  message.setTo(mailRequest.getToEmail());
                  message.setSubject(mailRequest.getSubject());
                  message.setText(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,templatePath + mailRequest.getTemplateName() + ".vm", ApplicationConstants.CHARSET_UTF8, model),true);
           }
      };
      this.javaMailSender.send(preparator);
  }
  </code></pre>
  
  <p>Please, help me to overcome from this issue. </p>
  
  <p>Thank you!</p>