Chapter 19. Sending email with Spring
This chapter covers
- Configuring Spring’s email abstraction
- Sending rich email messages
- Using templates to construct email messages
It’s no secret that email has become a common form of communication, displacing many traditional means of communication such as postal mail, telephone calls, and, to some degree, face-to-face communication. Email offers many of the same asynchronous benefits as the messaging options we discussed in chapter 17, only with humans as the senders and receivers. As soon as you click Send in your email client, you can move on to some other task, knowing that the recipient will eventually receive and (hopefully) read your email.
But humans aren’t always the senders of email. Frequently, email messages are sent by applications to users. Perhaps it’s an email confirmation of an order that a user placed on an eCommerce site, or maybe it’s an automated notification of an activity involving someone’s bank account. Whatever the subject, it’s likely that you’ll develop applications that need to send email messages. Fortunately, Spring is ready to help.
In chapter 17, you used Spring’s messaging support to asynchronously queue up jobs to send spittle alerts to other Spittr application users. But you left that task unfinished, because no email messages were sent. Let’s finish what you started by looking at how Spring abstracts the problem of sending email, and then use that abstraction to send spittle alert email messages.