title: Spring 4 mail configuration via java config
body: <p>Is there some example of how MailSender can be configured via java config? 
  All examples that I've seen uses xml to create needed beans:</p>
  
  <pre><code>&lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
     &lt;property name="host" value="mail.mycompany.com"/&gt;
  &lt;/bean&gt;
  
  &lt;!-- this is a template message that we can pre-load with default state --&gt;
   &lt;bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage"&gt;
   &lt;property name="from" value="customerservice@mycompany.com"/&gt;
   &lt;property name="subject" value="Your order"/&gt;
  &lt;/bean&gt;
  </code></pre>