The MailSender class

As we can expect, we will integrate with the SendGrid services through the REST APIs. In our case, we will use the reactive WebClient provided by Spring WebFlux.

Now, we will use the SendGrid API Key created in the previous section. Our MailSender class should look like this:

package springfive.airline.mailservice.domain.service;import org.springframework.beans.factory.annotation.Value;import org.springframework.http.HttpStatus;import org.springframework.http.ReactiveHttpOutputMessage;import org.springframework.stereotype.Service;import org.springframework.web.reactive.function.BodyInserter;import org.springframework.web.reactive.function.BodyInserters;import org.springframework.web.reactive.function.client.WebClient ...

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.