public class MailService {

  private JavaMailSenderImpl mailSender; 

  public MailService(JavaMailSenderImpl mailSender) {
    this.mailSender = mailSender;
  }

  public void sendMessagesAsMail(final String someText) throws MailException {

    final String mailText = "some mail text ...";

    MimeMessagePreparator preparator = new MimeMessagePreparator() {
      public void prepare(MimeMessage mimeMessage) throws Exception {

        mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
        mimeMessage.setFrom(new InternetAddress("[email protected]"));
        mimeMessage.setText(mailText);
      }
    };

    this.mailSender.send(preparator);
  }
}

servlet-context.xml
<bean id="mailSender" class="org.springframework.mail.javamail.
    <property name="host" value="${mail.server.address}"/>
    <property name="port" value="${mail.server.port}"/>
    <property name="username" value="${mail.server.username}"/>
    <property name="password" value="${mail.server.password}"/>
    <property name="protocol" value="${mail.server.protocol}"/>
</bean>

<bean class="ee.fin.eajatamine.services.AppMessageMailService">
    <constructor-arg name="mailSender" ref="mailSender"/>
</bean>
    
    
pom.xml
<!-- JavaMail dependency -->
<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
    <version>1.5.4</version>
</dependency>
    
<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
</dependency>