> For the complete documentation index, see [llms.txt](https://potoyang.gitbook.io/spring-in-action-v4/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://potoyang.gitbook.io/spring-in-action-v4/untitled-12/untitled-3.md).

# 19.1　配置 Spring 发送邮件

Spring Email 抽象的核心是 MailSender 接口。顾名思义，MailSender 的实现能够通过连接 Email 服务器实现邮件发送的功能，如图 19.1 所示。

![图 19.1 Spring 的 MailSender 接口是 Spring Email 抽象 API 的核心组件。它把Email发送给邮件服务器，由服务器进行邮件投递](https://3784153818-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LmcjU5gG__lBrRbUxBO%2F-LnvV6sbvwW0dzBsRTt4%2F-LnvVHvXS1sMBqWS2NX_%2F19.1%20mail%20sender.jpg?alt=media\&token=3eb0700d-18a0-4f71-8e71-1d0d3ad21a2e)

Spring 自带了一个 MailSender 的实现也就是 JavaMailSenderImpl，它会使用 JavaMail API 来发送 Email。Spring 应用在发送 Email 之前，我们必须要将 JavaMailSenderImpl 装配为 Spring 应用上下文中的一个 bean。
