Skip to content

Commit

Permalink
Add documentation about required value
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Oct 29, 2024
1 parent 49870be commit 6978f67
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions docs/src/main/asciidoc/mailer-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ To send a simple email, proceed as follows:
[source, java]
----
// Imperative API:
mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body."));
mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body.").setFrom("from@acme.org"));
// Reactive API:
Uni<Void> stage = reactiveMailer.send(Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body."));
Uni<Void> stage = reactiveMailer.send(Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body.").setFrom("from@acme.org"));
----

For example, you can use the `Mailer` in an HTTP endpoint as follows:
Expand All @@ -78,14 +78,14 @@ For example, you can use the `Mailer` in an HTTP endpoint as follows:
@GET
@Path("/imperative")
public void sendASimpleEmail() {
mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body"));
mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body").setFrom("from@acme.org"));
}
@GET
@Path("/reactive")
public Uni<Void> sendASimpleEmailAsync() {
return reactiveMailer.send(
Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body"));
Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body").setFrom("from@acme.org"));
}
----

Expand All @@ -96,6 +96,20 @@ You can create new `io.quarkus.mailer.Mail` instances from the constructor or fr
`Mail.withHtml` helper methods.
The `Mail` instance lets you add recipients (to, cc, or bcc), set the subject, headers, sender (from) address...

Most of these properties are optional, but the sender address is required. It can either be set on an individual `Mail` instances using

[source,java]
----
.setFrom("from@acme.org");
----

or a global default can be configured, using

[source,properties]
----
quarkus.mailer.from=from@acme.org
----

You can also send several `Mail` objects in one call:

[source, java]
Expand Down

0 comments on commit 6978f67

Please sign in to comment.