Uploaded image for project: 'Quarkus'
  1. Quarkus
  2. QUARKUS-5342

Add information about 'from' in mailer docs

XMLWordPrintable

      Direct preview link: https://quarkus-pr-main-44164-preview.surge.sh/version/main/guides/mailer-reference


      I recently used the mailer extension. When I copied and pasted the example from the [docs](https://quarkus.io/guides/mailer-reference), it didn't work.

      ```
      mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body."));
      ```

      I got a nasty exception:

      ```
      java.util.concurrent.CompletionException: io.vertx.core.impl.NoStackTraceThrowable: sender address is not present
      at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:79)
      at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)
      at io.smallrye.mutiny.groups.UniAwait.indefinitely(UniAwait.java:46)
      at io.quarkus.mailer.runtime.BlockingMailerImpl.send(BlockingMailerImpl.java:20)
      at org.acme.MailThing.doMail(MailThing.java:16)
      ...
      Caused by: io.vertx.core.impl.NoStackTraceThrowable: sender address is not present
      ```

      (The error was hidden, which didn't help, but that's a different issue.)

      I worked out I needed to set the from address, but https://quarkus.io/guides/mailer-reference didn't give enough information how to do that. It says

      > The Mail instance lets you add recipients (to, cc, or bcc), set the subject, headers, sender (from) address…​

      I tried a few variations, like `addSender`, `addHeader(`from`...`), `addFrom`, before I found `setFrom`. Since users have to use this method (or do it by config), we should make sure to include it in the reference.

      I've updated the opening examples so they work out of the box, and also added a bit of text to explain that a sender is required, and describe the two ways of doing it.

              Unassigned Unassigned
              olubyans@redhat.com Alexey Loubyansky
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: