Dims
Dims

Reputation: 51239

How to get email errors when sending emails in Quarkus?

I am sending emails with

public Response sendConfirmationEmail(String prefix, User user) {
    String emailConfirmToken = createEmailConfirmTokenIfRequired(user);
    verifyEmail
            .data("link", createEmailConfirmationUrl(prefix, user.getEmail(), emailConfirmToken))
            .data("emailConfirmToken", emailConfirmToken)
            .data("name", user.getName())
            .replyTo(replayTo)
            .to(user.getEmail())
            .subject(String.format("%s - Account Confirmation", appName)).send();
    return Response.status(Response.Status.CREATED).entity(user).build();

how to know if sendmail failed due to some reason like incorrect sendmail password or something?

Upvotes: 1

Views: 1438

Answers (1)

geoand
geoand

Reputation: 64079

When you are using io.quarkus.mailer.Mailer then send will thrown an exception if something goes wrong.

If you use io.quarkus.mailer.reactive.ReactiveMailer that returns a Uni which has a dedicated error handler.

Update

io.quarkus.mailer.MailTemplate's send method return Uni<Void> which you need to subscribe to. You current code does not do that.

Upvotes: 2

Related Questions