25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13 ■ Adding E-mail and Scheduling Tasks<br />

}<br />

}<br />

mailMessage.setSubject(subject);<br />

mailMessage.setText(message);<br />

mailSender.send(mailMessage);<br />

Listing 13-1 shows a MailSender and a SimpleMailMessage class; these helpers will send an e-mail passing the To<br />

recipients, the subject, and the message. So easy! Now you need to tell the <strong>Spring</strong> container what credentials you are<br />

going to use in order to send an e-mail. You can use any external e-mail account like Hotmail, Gmail, or Yahoo. This<br />

example will use the Gmail settings. See Listing 13-2 for the XML configuration.<br />

Listing 13-2. mydocuments-context.xml<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!