From 4dedad452845ce87339c3bf2139b4b976fa61bad Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 6 Jun 2022 19:58:07 +0200 Subject: [PATCH] template mail --- pom.xml | 4 ++++ .../java/com/covas/Resources/MailRessource.java | 13 +++++++++---- src/main/resources/templates/hello.txt | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/templates/hello.txt diff --git a/pom.xml b/pom.xml index f15c87c..7eafd45 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,10 @@ io.quarkus quarkus-resteasy-mutiny + + io.quarkus + quarkus-resteasy-qute + io.quarkus quarkus-junit5 diff --git a/src/main/java/com/covas/Resources/MailRessource.java b/src/main/java/com/covas/Resources/MailRessource.java index b87aee6..cc979dc 100644 --- a/src/main/java/com/covas/Resources/MailRessource.java +++ b/src/main/java/com/covas/Resources/MailRessource.java @@ -9,7 +9,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.Response; import io.quarkus.mailer.Mail; -import io.quarkus.mailer.Mailer; +import io.quarkus.mailer.MailTemplate; import io.quarkus.mailer.reactive.ReactiveMailer; @@ -19,12 +19,17 @@ public class MailRessource { @Inject private ReactiveMailer mail; + @Inject + private MailTemplate hello; + @GET + @Path("async") public CompletionStage sendMail(){ - return mail.send(Mail.withText("valcze80@gmail.com", "async", "toto")) - .subscribeAsCompletionStage() - .thenApply(x -> Response.accepted().build()); + //return mail.send(Mail.withText("valcze80@gmail.com", "async", "toto")) + //.subscribeAsCompletionStage() + //.thenApply(x -> Response.accepted().build()); + return hello.to("valcze80@gmail.com").subject("test").data("name", "Robert").send().subscribeAsCompletionStage().thenApply(x -> Response.accepted().build()); } diff --git a/src/main/resources/templates/hello.txt b/src/main/resources/templates/hello.txt new file mode 100644 index 0000000..9a61208 --- /dev/null +++ b/src/main/resources/templates/hello.txt @@ -0,0 +1 @@ +Coucou {name} ! \ No newline at end of file