title: send a message using freemarker
body: <p>I need to send a letter with the body:</p>
  
  <pre><code> Lector {LectorName} had created a new course
   ----------------------------------------------------
   Name:        {CourseName}
   Category:    {CourseCategory}
   Description: {CourseDescription}
   Links:       {CourseLinks}
   ----------------------------------------------------
   Please, review this course at {CourseApproveLink}
  </code></pre>
  
  <p>I made on a page freemarker</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
   &lt;head&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;p&gt;         ${LectorName} had created a new course&lt;/p&gt;
  &lt;p&gt;----------------------------------------------------&lt;/p&gt;
  &lt;p&gt;Name: ${Course.title}&lt;/p&gt;
  &lt;p&gt;Category: ${Course.category.name}&lt;/p&gt;
  &lt;p&gt;Description: ${Course.descr}&lt;/p&gt;
   &lt;p&gt;Links: ${Course.links}&lt;/p&gt;
   &lt;p&gt;----------------------------------------------------&lt;/p&gt;
    &lt;p&gt;Please, review this course at ${CourseApproveLink}&lt;/p&gt;
    &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>
  
  <p>how to fill it and pass the values in the method of sending the letter?
  Here is my code. My method sendMail and Bean "mailSender" with my settings.
  It is necessary to do so new MimeMessage(session) ? 
  How do I get the settings from the bean into the session?</p>
  
  <pre><code>@Service("mailService")
  public class MailService {
  
  @Autowired
  private MailSender mailSender;
  @Autowired
  private SimpleMailMessage alertMailMessage;
  
  @Resource(name = "freemarkerEmailConfig")
  private Configuration emailConfiguration;
  
  public void sendMail(String from, String to, String subject, String body) {
  
  SimpleMailMessage message = new SimpleMailMessage();
  
  message.setFrom(from);
  message.setTo(to);
  message.setSubject(subject);
   message.setText(body);
  
  mailSender.send(message);
  
  }
  
  public void sendAlertMail(String alert) {
  
  SimpleMailMessage mailMessage = new SimpleMailMessage(alertMailMessage);
  mailMessage.setText(alert);
  mailSender.send(mailMessage);
  
  }
  
  }
  
  
  
  &lt;bean id="mailSender"  class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
  
      &lt;property name="host" value="smtp.mail.ru" /&gt;
      &lt;property name="port" value="465" /&gt;
      &lt;property name="username" value="user@mail.ru" /&gt;
      &lt;property name="password" value="***********" /&gt;
      &lt;property name="javaMailProperties"&gt;
          &lt;props&gt;
              &lt;prop key="mail.transport.protocol"&gt;smtp&lt;/prop&gt;
              &lt;prop key="mail.smtp.auth"&gt;true&lt;/prop&gt;
              &lt;prop key="mail.smtp.ssl.enable"&gt;true&lt;/prop&gt;
              &lt;prop key="mail.debug"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="alertMailMessage"  class="org.springframework.mail.SimpleMailMessage"&gt;
      &lt;property name="from"&gt;
          &lt;value&gt;dima4nolimit@mail.ru&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="to"&gt;
          &lt;value&gt;bizanrus@mail.ru&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="subject"
          value="Alert - Exception occurred. Please investigate" /&gt;
  
      &lt;/bean&gt;
  </code></pre>