The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Mailerリファレンスガイド

このガイドは、 Mailer 入門ガイドの続編です。このガイドでは、Quarkus Mailerの設定と使用方法について詳しく説明しています。

Mailerエクステンション

Mailerを使用するには、 quarkus-mailer エクステンションを追加する必要があります。

次のコマンドでプロジェクトにエクステンションを追加することができます:

> ./mvnw quarkus:add-extensions -Dextensions="mailer"

もしくは、以下の依存関係をプロジェクトに追加します:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-mailer</artifactId>
</dependency>

Mailerへのアクセス

次のようにしてアプリケーションにMailerをインジェクトすることができます:

@Inject
Mailer mailer;

@Inject
ReactiveMailer reactiveMailer;

APIは2つあります:

  • io.quarkus.mailer.Mailer は、命令型(ブロッキング、同期)APIを提供しています。

  • io.quarkus.mailer.reactive.ReactiveMailer は、リアクティブ(ノンブロッキング、非同期)なAPIを提供しています。

この2つのAPIは機能的には同等です。実際、 Mailer の実装は、 ReactiveMailer の実装の上に構築されています。
非推奨

io.quarkus.mailer.ReactiveMailer は、 io.quarkus.mailer.reactive.ReactiveMailer に置き換えられ非推奨となりました。

簡単なメールを送信するには、次のようにします:

// Imperative API:
mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body."));
// Reactive API:
Uni<Void> stage = reactiveMailer.send(Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body."));

例えば、 Mailer を HTTP のエンドポイントで使用する場合は次のようになります:

@GET
@Path("/imperative")
public void sendASimpleEmail() {
    mailer.send(Mail.withText("to@acme.org", "A simple email from quarkus", "This is my body"));
}

@GET
@Path("/reactive")
public Uni<Void> sendASimpleEmailAsync() {
    return reactiveMailer.send(
            Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body"));
}

メールオブジェクトの作成

Mailerでは、 io.quarkus.mailer.Mail のオブジェクトを送信することができます。新しい io.quarkus.mailer.Mail インスタンスは、コンストラクタや Mail.withText および Mail.withHtml といったヘルパーメソッドから作成できます。 Mail インスタンスでは、受信者(to、cc、bcc)の追加、件名、ヘッダー、送信者(from)アドレスの設定などができます。

また、1回の呼び出しで複数の Mail オブジェクトを送信することもできます:

mailer.send(mail1, mail2, mail3);

添付ファイルの送信

添付ファイルを送信するには、 io.quarkus.mailer.Mail インスタンスの addAttachment メソッドを使用するだけです:

@GET
@Path("/attachment")
public void sendEmailWithAttachment() {
        mailer.send(Mail.withText("clement.escoffier@gmail.com", "An email from quarkus with attachment",
                "This is my body")
                .addAttachment("my-file-1.txt",
                        "content of my file".getBytes(), "text/plain")
                .addAttachment("my-file-2.txt",
                        new File("my-file.txt"), "text/plain")
        );
}

添付ファイルは、(スニペットで示したように)生のバイトまたはファイルから作成できます。ファイルは、アプリケーションのワーキングディレクトリを基準に解決されることに注意してください。

添付ファイルがインライン化されたHTMLメールの送信

HTMLメールを送信する際に、インラインで添付ファイルを追加することができます。例えば、メールに画像を添付して送信すると、その画像がメールの内容に表示されます。画像ファイルを META-INF/resources フォルダーに置く場合は、ファイルのフルパスを指定する必要があります。 例えばMETA-INF/resources/quarkus-logo.png です。そうしないと、Quarkusはルートディレクトリでファイルを探します。

@GET
@Path("/html")
public void sendingHTML() {
    String body = "<strong>Hello!</strong>" + "\n" +
        "<p>Here is an image for you: <img src=\"cid:my-image@quarkus.io\"/></p>" +
        "<p>Regards</p>";
    mailer.send(Mail.withHtml("to@acme.org", "An email in HTML", body)
        .addInlineAttachment("quarkus-logo.png",
            new File("quarkus-logo.png"),
            "image/png", "<my-image@quarkus.io>"));
}

content-id の 形式と参照に注意してください。仕様上、インライン添付ファイルを作成する際には、content-idは以下のように構成する必要があります。 <id@domain> . <> の間に content-id を挟まない場合は、自動的にラップされます。添付ファイルを参照したい場合、例えば src 属性で参照したい場合は cid:id@domain を使用してください( <> は使用しないでください)。

Quteテンプレートに基づくメッセージ Body

また、 Quteのテンプレート を使って、本文が自動的に作成されるメールを送信することも可能です。

Javaコードでタイプセーフ・メール・テンプレートを定義することができます。 クラスを @io.quarkus.qute.CheckedTemplate でアノテートするだけで、 MailTemplate を返す static native メソッドすべてが、型安全なメール・テンプレートと、それらが必要とするパラメータのリストを定義するために使われます:

import io.quarkus.mailer.MailTemplate;
import io.quarkus.qute.CheckedTemplate;

@Path("")
public class MailingResource {

    @CheckedTemplate
    static class Templates {
        public static native MailTemplateInstance hello(String name); (1)
    }

    @GET
    @Path("/mail")
    public Uni<Void> send() {
        // the template looks like: Hello {name}! (2)
        return Templates.hello("John")
           .to("to@acme.org")  (3)
           .subject("Hello from Qute template")
           .send(); (4)
    }
}
1 規約では、テンプレートの位置を特定するために、囲んでいるクラス名とメソッド名が使用されます。この例では、 src/main/resources/templates/MailingResource/hello.htmlsrc/main/resources/templates/MailingResource/hello.txt のテンプレートを使ってメッセージ本文を作成します。
2 テンプレートで使用するデータを設定します。
3 メールテンプレートのインスタンスを作成し、受信者を設定します。
4 MailTemplate.send() がレンダリングのトリガーとなり、終了すると Mailer のインスタンスを介してメールを送信します。

あるいは、 io.quarkus.mailer.MailTemplate を実装する Java レコードを使用します。 レコード・コンポーネントはテンプレート・パラメータを表します。

import io.quarkus.mailer.MailTemplate;
import io.quarkus.qute.CheckedTemplate;

@Path("")
public class MailingResource {

    record hello(String name) implements MailTemplateInstance { (1)
    }

    @GET
    @Path("/mail")
    public Uni<Void> send() {
        // the template looks like: Hello {name}! (2)
        return new hello("John")
           .to("to@acme.org")  (3)
           .subject("Hello from Qute template")
           .send(); (4)
    }
}
1 規約では、テンプレートを見つけるために、クラス名とレコード名が使用されます。このケースでは、 src/main/resources/templates/MailingResource/hello.htmlsrc/main/resources/templates/MailingResource/hello.txt のテンプレートを使用してメッセージ本文を作成します。
2 テンプレートで使用するデータを設定します。
3 メールテンプレートのインスタンスを作成し、受信者を設定します。
4 MailTemplate.send() がレンダリングのトリガーとなり、終了すると Mailer のインスタンスを介してメールを送信します。

また、タイプセーフのテンプレートを使わずに行うこともできます:

import io.quarkus.mailer.MailTemplate;

@Inject
@Location("hello")
MailTemplate hello; (1)

@GET
@Path("/mail")
public Uni<Void> send() {
    return hello.to("to@acme.org") (2)
       .subject("Hello from Qute template")
       .data("name", "John") (3)
       .send() (4)
}
1 @Location 修飾子が指定されていない場合は、フィールド名を使ってテンプレートを探します。それ以外の場合は、指定された場所としてテンプレートを検索します。この例では、 src/main/resources/templates/hello.htmlsrc/main/resources/templates/hello.txt のテンプレートを使ってメッセージ・ボディを作成します。
2 メールテンプレートのインスタンスを作成し、受信者を設定します。
3 テンプレートで使用するデータを設定します。
4 MailTemplate.send() がレンダリングのトリガーとなり、終了すると Mailer のインスタンスを介してメールを送信します。
挿入されたメールテンプレートはビルド時に検証されます。 src/main/resources/templates に一致するテンプレートがない場合、ビルドは失敗します。

実行モデル

リアクティブ型Mailerはノンブロッキングで、結果はI/Oスレッドで提供されます。このトピックの詳細については、 Quarkus Reactive Architectureのドキュメントを参照してください。

非リアクティブ型Mailerは、メッセージがSMTPサーバーに送信されるまでブロックします。これは、メッセージが配信されたことを意味するのではなく、配信を担当するSMTPサーバに正常に送信されたことを意味することに注意してください。

メール送信のテスト

開発中やテスト中にメールを送信するのは非常に不便であるため、 quarkus.mailer.mock boolean設定を true に設定することで、 実際のメール送信は行われず、代わりに標準出力にメールが出力され、 MockMailbox Beanにメールが収集されます。 これは、Quarkusを開発モードまたはテストモードで実行している場合のデフォルトです。

そして、例えばRESTエンドポイントでメールが送信されたことを検証するテストを書くことができます:

@QuarkusTest
class MailTest {

    private static final String TO = "foo@quarkus.io";

    @Inject
    MockMailbox mailbox;

    @BeforeEach
    void init() {
        mailbox.clear();
    }

    @Test
    void testTextMail() throws MessagingException, IOException {
        // call a REST endpoint that sends email
        given()
        .when()
        .get("/send-email")
        .then()
           .statusCode(202)
           .body(is("OK"));

        // verify that it was sent
        List<Mail> sent = mailbox.getMessagesSentTo(TO);
        assertThat(sent).hasSize(1);
        Mail actual = sent.get(0);
        assertThat(actual.getText()).contains("Wake up!");
        assertThat(actual.getSubject()).isEqualTo("Alarm!");

        assertThat(mailbox.getTotalMessagesSent()).isEqualTo(6);
    }
}

Quarkus Mailpit エクステンションを使用すると、 メール 送信のテストやデバッグを行うための優れたUIである Mailpit 用のDev Servicesが提供されます。

Vert.xのメールクライアントの使用

Quarkus Mailerは、 Vert.xメールクライアント の上に実装されており、非同期でノンブロッキングな方法でメールを送信することができます。メールの送信方法を細かく制御する必要がある場合、例えばメッセージのIDを取得する必要がある場合などの場合は、基礎となるクライアントを注入して直接使用することができます。

@Inject MailClient client;

3種類のAPIが公開されています:

  • Mutinyクライアント (io.vertx.mutiny.ext.mail.MailClient)

  • ベアクライアント (io.vertx.ext.mail.MailClient)

各APIの詳細および最適なAPIの選択方法については、 Vert.x のガイド をご参照ください。

取得した MailClient は、上で示した設定プロパティを使って設定します。 独自のインスタンスを作成し、独自の設定を渡すこともできます。

ネイティブ実行可能ファイルでのSSLの使用

なお、メーラーのSSLを有効にしていて、ネイティブ実行可能ファイルをビルドする場合は、SSLのサポートを有効にする必要があります。詳しくは、 ネイティブイメージでのSSLの利用をご参照ください。

SMTP認証情報の設定

quarkus.mailer.password のような機密データは暗号化することをお勧めします。一つの方法として、HashiCorp Vaultのような安全なストアに値を保存し、設定からそれを参照することができます。例えば、Vaultがパス myapps/myapp/myconfig にキー mail-password を含んでいるとすると、Mailerエクステンションは次のように簡単に設定できます。

...
# path within the kv secret engine where is located the application sensitive configuration
# This uses the https://github.com/quarkiverse/quarkus-vault extension.
quarkus.vault.secret-config-kv-path=myapps/myapp/myconfig

...
quarkus.mailer.password=${mail-password}

パスワードの値は、起動時に一度だけ評価されることに注意してください。Vault で mail-password が変更された場合、新しい値を取得するには、アプリケーションを再起動するしかありません。

Vaultを使用するには、 Quarkus Vault エクステンションが必要です。このエクステンションとその設定の詳細については、 エクステンションのドキュメント を参照してください。
メーラーの設定の詳細については、 設定リファレンス を参照してください。

トラストストアの設定

SMTPにトラストストアが必要な場合は、以下のように設定します:

quarkus.mailer.host=...
quarkus.mailer.port=...
quarkus.mailer.ssl=true
quarkus.mailer.trust-store.paths=truststore.jks # the path to your trust store
quarkus.mailer.trust-store.password=secret # the trust store password if any
quarkus.mailer.trust-store.type=JKS # the type of trust store if it can't be deduced from the file extension

Quarkus mailerは、JKS、PCKS#12、PEMのトラストストアをサポートしています。PEMでは、複数のファイルを設定することができます。JKSとPCKS#12では、パスワードが存在する場合、設定することができます。

quarkus.mailer.trust-store.type はオプションで、トラストストアのタイプを設定できます( JKSPEMPCKS の中から選択)。設定されていない場合、Quarkusはファイル名からタイプを推測しようとします。

また、 quarkus.mailer.trust-all=true を設定し、認証をバイパスするように設定することも可能です。

複数のmailer設定

アプリケーションによっては、異なるSMTPサーバーを経由してメールを送信する必要があります。

この使用例は、Quarkusで完全にサポートされており、複数のmailerを設定することができます:

quarkus.mailer.from=your-from-address@gmail.com (1)
quarkus.mailer.host=smtp.gmail.com

quarkus.mailer.aws.from=your-from-address@gmail.com (2)
quarkus.mailer.aws.host=${ses.smtp}
quarkus.mailer.aws.port=587

quarkus.mailer.sendgrid.from=your-from-address@gmail.com (3)
quarkus.mailer.sendgrid.host=${sendgrid.smtp-host}
quarkus.mailer.sendgrid.port=465
1 デフォルトのmailerの設定。
2 aws という名前のmailerの設定 .
3 sendgrid という名前のmailerの設定。

そして、 @MailerName CDI修飾子を使用して、名前付きメーラーにアクセスします:

@Inject (1)
Mailer mailer;

@Inject (1)
ReactiveMailer reactiveMailer;

@Inject (1)
@Location("hello")
MailTemplate mailTemplate;

@Inject
@MailerName("aws") (2)
Mailer mailer;

@Inject
@MailerName("aws") (2)
ReactiveMailer reactiveMailer;

@Inject
@MailerName("aws") (2)
@Location("hello")
MailTemplate mailTemplate;

@Inject
@MailerName("sendgrid") (3)
Mailer mailer;

@Inject
@MailerName("sendgrid") (3)
ReactiveMailer reactiveMailer;

@Inject
@MailerName("sendgrid") (3)
@Location("hello")
MailTemplate mailTemplate;
1 デフォルトの設定で修飾子なしでインスタンスを注入。
2 @MailerName("aws")` の修飾子で`aws` の設定のインスタンスを注入。
3 @MailerName("sendgrid") の修飾子で sendgrid の設定のインスタンスを注入。

@CheckedTemplate を使用したタイプセーフテンプレートは、現在、デフォルトのメーラー設定にのみ対応しています。

名前付きメーラーの設定には、 MailTemplate 注入を使用してください。

ここでは、一般的なメールサービスで使用するための設定について説明します。

Gmail特有の設定

GmailのSMTPサーバーを使用する場合は、まず、 Google Account > Security > App passwords で専用のパスワードを作成するか、 https://myaccount.google.com/apppasswords にアクセスしてください。

App passwords ページにアクセスするには、 https://myaccount.google.com/security 、2段階認証をオンにする必要があります。

完了したら、 application.properties に以下のプロパティを追加して、Quarkusアプリケーションを設定することができます:

TLSの場合:

quarkus.mailer.auth-methods=DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN
quarkus.mailer.from=YOUREMAIL@gmail.com
quarkus.mailer.host=smtp.gmail.com
quarkus.mailer.port=587
quarkus.mailer.start-tls=REQUIRED
quarkus.mailer.username=YOUREMAIL@gmail.com
quarkus.mailer.password=YOURGENERATEDAPPLICATIONPASSWORD

quarkus.mailer.mock=false # In dev mode, prevent from using the mock SMTP server

SSLの場合:

quarkus.mailer.auth-methods=DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN
quarkus.mailer.from=YOUREMAIL@gmail.com
quarkus.mailer.host=smtp.gmail.com
quarkus.mailer.port=465
quarkus.mailer.ssl=true
quarkus.mailer.username=YOUREMAIL@gmail.com
quarkus.mailer.password=YOURGENERATEDAPPLICATIONPASSWORD

quarkus.mailer.mock=false # In dev mode, prevent from using the mock SMTP server

Quarkus Mailer が Gmailでのパスワード認証をサポートするには、 quarkus.mailer.auth-methods 設定オプションが必要です。 Mailer と Gmail の両方が XOAUTH2 をデフォルトとしており、アプリケーションの登録やトークンの取得などが必要です。

AWS SES - Simple Email Service

前提条件

  1. SES Identity Checkでは、手順に従ってDKIM認証を設定します

  2. SMTPエンドポイントを https://us-east-1.console.aws.amazon.com/ses/home から取得します。例: email-smtp.us-east-1.amazonaws.com

  3. 必要に応じてSMTP認証情報を作成します

  4. サンドボックスの場合は、受信者の確認も行います(メール認証を使用する)

設定

ses.smtp=...
ses.user=...
ses.password=...
ses.from=an email address from the verified domain

quarkus.mailer.host=${ses.smtp}
quarkus.mailer.port=587
quarkus.mailer.username=${ses.user}
quarkus.mailer.password=${ses.password}
quarkus.mailer.start-tls=REQUIRED
quarkus.mailer.login=REQUIRED
quarkus.mailer.from=${ses.from}

quarkus.mailer.mock=false # In dev mode, prevent from using the mock SMTP server

MailJet

MailJetの統合は、SMTPリレーで使用されます。このSMTPサーバーを使ってメールを送信することになります。

前提条件

  1. MailJetのアカウントとAPIキー/シークレットキーを作成します

  2. 送信者アドレスの認証(SPF + DKIM)と、認証済みリストへの明示的なメール追加が必要です

設定

mailjet.smtp-host=in-v3.mailjet.com
mailjet.api-key=...
mailjet.secret-key=...
mailjet.from=the verified sender address

quarkus.mailer.host=${mailjet.smtp-host}
quarkus.mailer.port=465
quarkus.mailer.username=${mailjet.api-key}
quarkus.mailer.password=${mailjet.secret-key}
quarkus.mailer.start-tls=OPTIONAL
quarkus.mailer.ssl=true
quarkus.mailer.login=REQUIRED
quarkus.mailer.from=${mailjet.from}

quarkus.mailer.mock=false # In dev mode, prevent from using the mock SMTP server

Sendgrid

前提条件

  • 指示に従って、DKIMを使用して送信ドメインを確認します

設定

sendgrid.smtp-host=smtp.sendgrid.net
sendgrid.username=apikey
sendgrid.key=...

quarkus.mailer.host=${sendgrid.smtp-host}
quarkus.mailer.port=465
quarkus.mailer.username=${sendgrid.username}
quarkus.mailer.password=${sendgrid.key}
quarkus.mailer.start-tls=OPTIONAL
quarkus.mailer.ssl=true
quarkus.mailer.login=REQUIRED
quarkus.mailer.from=...

quarkus.mailer.mock=false # In dev mode, prevent from using the mock SMTP server

Mailer設定リファレンス

ビルド時に固定される構成プロパティ - 他のすべての構成プロパティは実行時にオーバーライド可能

Configuration property

デフォルト

Caches data from attachment’s Stream to a temporary file. It tries to delete it after sending email.

Environment variable: QUARKUS_MAILER_CACHE_ATTACHMENTS

Show more

boolean

false

Sets the default from attribute when not specified in the io.quarkus.mailer.Mail instance. It’s the sender email address.

Environment variable: QUARKUS_MAILER_FROM

Show more

string

Enables the mock mode. When enabled, mails are not sent, but stored in an in-memory mailbox. The content of the emails is also printed on the console.

Disabled by default on PROD, enabled by default on DEV and TEST modes.

Environment variable: QUARKUS_MAILER_MOCK

Show more

boolean

Sets the default bounce email address. A bounced email, or bounce, is an email message that gets rejected by a mail server.

Environment variable: QUARKUS_MAILER_BOUNCE_ADDRESS

Show more

string

Sets the SMTP host name.

Environment variable: QUARKUS_MAILER_HOST

Show more

string

localhost

The SMTP port. The default value depends on the configuration. The port 25 is used as default when ssl is disabled. This port continues to be used primarily for SMTP relaying. SMTP relaying is the transmission of email from email server to email server. The port 587 is the default port when ssl is enabled. It ensures that email is submitted securely. Note that the port 465 may be used by SMTP servers, however, IANA has reassigned a new service to this port, and it should no longer be used for SMTP communications.

Environment variable: QUARKUS_MAILER_PORT

Show more

int

Sets the username to connect to the SMTP server.

Environment variable: QUARKUS_MAILER_USERNAME

Show more

string

Sets the password to connect to the SMTP server.

Environment variable: QUARKUS_MAILER_PASSWORD

Show more

string

Enables or disables the TLS/SSL.

Environment variable: QUARKUS_MAILER_SSL

Show more

boolean

false

Set whether all server certificates should be trusted. This option is only used when ssl is enabled.

Environment variable: QUARKUS_MAILER_TRUST_ALL

Show more

boolean

Sets the max number of open connections to the mail server.

Environment variable: QUARKUS_MAILER_MAX_POOL_SIZE

Show more

int

10

Sets the hostname to be used for HELO/EHLO and the Message-ID.

Environment variable: QUARKUS_MAILER_OWN_HOST_NAME

Show more

string

Sets if connection pool is enabled. If the connection pooling is disabled, the max number of sockets is enforced nevertheless.

Environment variable: QUARKUS_MAILER_KEEP_ALIVE

Show more

boolean

true

Disable ESMTP. The RFC-1869 states that clients should always attempt EHLO as first command to determine if ESMTP is supported, if this returns an error code, HELO is tried to use the regular SMTP command.

Environment variable: QUARKUS_MAILER_DISABLE_ESMTP

Show more

boolean

false

Sets the TLS security mode for the connection. Either DISABLED, OPTIONAL or REQUIRED.

Environment variable: QUARKUS_MAILER_START_TLS

Show more

string

OPTIONAL

Enables DKIM signing.

Environment variable: QUARKUS_MAILER_DKIM_ENABLED

Show more

boolean

false

Configures the PKCS#8 format private key used to sign the email.

Environment variable: QUARKUS_MAILER_DKIM_PRIVATE_KEY

Show more

string

Configures the PKCS#8 format private key file path.

Environment variable: QUARKUS_MAILER_DKIM_PRIVATE_KEY_PATH

Show more

string

Configures the Agent or User Identifier (AUID).

Environment variable: QUARKUS_MAILER_DKIM_AUID

Show more

string

Configures the selector used to query the public key.

Environment variable: QUARKUS_MAILER_DKIM_SELECTOR

Show more

string

Configures the Signing Domain Identifier (SDID).

Environment variable: QUARKUS_MAILER_DKIM_SDID

Show more

string

Configures the canonicalization algorithm for signed headers.

Environment variable: QUARKUS_MAILER_DKIM_HEADER_CANON_ALGO

Show more

simple, relaxed

Configures the canonicalization algorithm for mail body.

Environment variable: QUARKUS_MAILER_DKIM_BODY_CANON_ALGO

Show more

simple, relaxed

Configures the body limit to sign. Must be greater than zero.

Environment variable: QUARKUS_MAILER_DKIM_BODY_LIMIT

Show more

int

Configures to enable or disable signature sign timestamp.

Environment variable: QUARKUS_MAILER_DKIM_SIGNATURE_TIMESTAMP

Show more

boolean

Configures the expire time in seconds when the signature sign will be expired. Must be greater than zero.

Environment variable: QUARKUS_MAILER_DKIM_EXPIRE_TIME

Show more

Configures the signed headers in DKIM, separated by commas. The order in the list matters.

Environment variable: QUARKUS_MAILER_DKIM_SIGNED_HEADERS

Show more

list of string

Sets the login mode for the connection. Either NONE, @{code DISABLED}, OPTIONAL, REQUIRED or XOAUTH2.

  • DISABLED means no login will be attempted

  • NONE means a login will be attempted if the server supports in and login credentials are set

  • REQUIRED means that a login will be attempted if the server supports it and the send operation will fail otherwise

  • XOAUTH2 means that a login will be attempted using Google Gmail Oauth2 tokens

Environment variable: QUARKUS_MAILER_LOGIN

Show more

string

NONE

Sets the allowed authentication methods. These methods will be used only if the server supports them. If not set, all supported methods may be used. The list is given as a space separated list, such as DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN.

Environment variable: QUARKUS_MAILER_AUTH_METHODS

Show more

string

Sets the trust store password if any. Note that the password is only used for JKS and PCK#12 trust stores.

Environment variable: QUARKUS_MAILER_TRUSTSTORE_PASSWORD

Show more

string

Sets the location of the trust store files. If you use JKS or PCK#12, only one path is allowed. If you use PEM files, you can specify multiple paths.

The relative paths are relative to the application working directly.

Environment variable: QUARKUS_MAILER_TRUSTSTORE_PATHS

Show more

list of string

Sets the trust store type. By default, it guesses the type from the file name extension. For instance, truststore.pem will be seen as a PEM file, while truststore.jks will be seen as a JKS file. truststore.p12 and truststore.pfx will both be seen as PKCS#12 files. Accepted values are: JKS, PEM, PKCS.

Environment variable: QUARKUS_MAILER_TRUSTSTORE_TYPE

Show more

string

Whether the mail should always been sent as multipart even if they don’t have attachments. When sets to true, the mail message will be encoded as multipart even for simple mails without attachments.

Environment variable: QUARKUS_MAILER_MULTI_PART_ONLY

Show more

boolean

false

Sets if sending allows recipients errors. If set to true, the mail will be sent to the recipients that the server accepted, if any.

Environment variable: QUARKUS_MAILER_ALLOW_RCPT_ERRORS

Show more

boolean

false

Enables or disables the pipelining capability if the SMTP server supports it.

Environment variable: QUARKUS_MAILER_PIPELINING

Show more

boolean

true

Sets the connection pool cleaner period. Zero disables expiration checks and connections will remain in the pool until they are closed.

Environment variable: QUARKUS_MAILER_POOL_CLEANER_PERIOD

Show more

Duration

PT1S

Set the keep alive timeout for the SMTP connection. This value determines how long a connection remains unused in the pool before being evicted and closed. A timeout of 0 means there is no timeout.

Environment variable: QUARKUS_MAILER_KEEP_ALIVE_TIMEOUT

Show more

Duration

PT300S

Sets the workstation used on NTLM authentication.

Environment variable: QUARKUS_MAILER_NTLM_WORKSTATION

Show more

string

Sets the domain used on NTLM authentication.

Environment variable: QUARKUS_MAILER_NTLM_DOMAIN

Show more

string

Allows sending emails to these recipients only.

Approved recipients are compiled to a Pattern and must be a valid regular expression. The created Pattern is case-insensitive as emails are case insensitive. Provided patterns are trimmed before being compiled.

Environment variable: QUARKUS_MAILER_APPROVED_RECIPIENTS

Show more

list of Pattern

Log rejected recipients as warnings.

If false, the rejected recipients will be logged at the DEBUG level.

Environment variable: QUARKUS_MAILER_LOG_REJECTED_RECIPIENTS

Show more

boolean

false

Additional named mailers

デフォルト

Sets the default from attribute when not specified in the io.quarkus.mailer.Mail instance. It’s the sender email address.

Environment variable: QUARKUS_MAILER__MAILER_NAME__FROM

Show more

string

Enables the mock mode. When enabled, mails are not sent, but stored in an in-memory mailbox. The content of the emails is also printed on the console.

Disabled by default on PROD, enabled by default on DEV and TEST modes.

Environment variable: QUARKUS_MAILER__MAILER_NAME__MOCK

Show more

boolean

Sets the default bounce email address. A bounced email, or bounce, is an email message that gets rejected by a mail server.

Environment variable: QUARKUS_MAILER__MAILER_NAME__BOUNCE_ADDRESS

Show more

string

Sets the SMTP host name.

Environment variable: QUARKUS_MAILER__MAILER_NAME__HOST

Show more

string

localhost

The SMTP port. The default value depends on the configuration. The port 25 is used as default when ssl is disabled. This port continues to be used primarily for SMTP relaying. SMTP relaying is the transmission of email from email server to email server. The port 587 is the default port when ssl is enabled. It ensures that email is submitted securely. Note that the port 465 may be used by SMTP servers, however, IANA has reassigned a new service to this port, and it should no longer be used for SMTP communications.

Environment variable: QUARKUS_MAILER__MAILER_NAME__PORT

Show more

int

Sets the username to connect to the SMTP server.

Environment variable: QUARKUS_MAILER__MAILER_NAME__USERNAME

Show more

string

Sets the password to connect to the SMTP server.

Environment variable: QUARKUS_MAILER__MAILER_NAME__PASSWORD

Show more

string

Enables or disables the TLS/SSL.

Environment variable: QUARKUS_MAILER__MAILER_NAME__SSL

Show more

boolean

false

Set whether all server certificates should be trusted. This option is only used when ssl is enabled.

Environment variable: QUARKUS_MAILER__MAILER_NAME__TRUST_ALL

Show more

boolean

Sets the max number of open connections to the mail server.

Environment variable: QUARKUS_MAILER__MAILER_NAME__MAX_POOL_SIZE

Show more

int

10

Sets the hostname to be used for HELO/EHLO and the Message-ID.

Environment variable: QUARKUS_MAILER__MAILER_NAME__OWN_HOST_NAME

Show more

string

Sets if connection pool is enabled. If the connection pooling is disabled, the max number of sockets is enforced nevertheless.

Environment variable: QUARKUS_MAILER__MAILER_NAME__KEEP_ALIVE

Show more

boolean

true

Disable ESMTP. The RFC-1869 states that clients should always attempt EHLO as first command to determine if ESMTP is supported, if this returns an error code, HELO is tried to use the regular SMTP command.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DISABLE_ESMTP

Show more

boolean

false

Sets the TLS security mode for the connection. Either DISABLED, OPTIONAL or REQUIRED.

Environment variable: QUARKUS_MAILER__MAILER_NAME__START_TLS

Show more

string

OPTIONAL

Enables DKIM signing.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_ENABLED

Show more

boolean

false

Configures the PKCS#8 format private key used to sign the email.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_PRIVATE_KEY

Show more

string

Configures the PKCS#8 format private key file path.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_PRIVATE_KEY_PATH

Show more

string

Configures the Agent or User Identifier (AUID).

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_AUID

Show more

string

Configures the selector used to query the public key.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_SELECTOR

Show more

string

Configures the Signing Domain Identifier (SDID).

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_SDID

Show more

string

Configures the canonicalization algorithm for signed headers.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_HEADER_CANON_ALGO

Show more

simple, relaxed

Configures the canonicalization algorithm for mail body.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_BODY_CANON_ALGO

Show more

simple, relaxed

Configures the body limit to sign. Must be greater than zero.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_BODY_LIMIT

Show more

int

Configures to enable or disable signature sign timestamp.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_SIGNATURE_TIMESTAMP

Show more

boolean

Configures the expire time in seconds when the signature sign will be expired. Must be greater than zero.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_EXPIRE_TIME

Show more

Configures the signed headers in DKIM, separated by commas. The order in the list matters.

Environment variable: QUARKUS_MAILER__MAILER_NAME__DKIM_SIGNED_HEADERS

Show more

list of string

Sets the login mode for the connection. Either NONE, @{code DISABLED}, OPTIONAL, REQUIRED or XOAUTH2.

  • DISABLED means no login will be attempted

  • NONE means a login will be attempted if the server supports in and login credentials are set

  • REQUIRED means that a login will be attempted if the server supports it and the send operation will fail otherwise

  • XOAUTH2 means that a login will be attempted using Google Gmail Oauth2 tokens

Environment variable: QUARKUS_MAILER__MAILER_NAME__LOGIN

Show more

string

NONE

Sets the allowed authentication methods. These methods will be used only if the server supports them. If not set, all supported methods may be used. The list is given as a space separated list, such as DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN.

Environment variable: QUARKUS_MAILER__MAILER_NAME__AUTH_METHODS

Show more

string

Sets the trust store password if any. Note that the password is only used for JKS and PCK#12 trust stores.

Environment variable: QUARKUS_MAILER__MAILER_NAME__TRUSTSTORE_PASSWORD

Show more

string

Sets the location of the trust store files. If you use JKS or PCK#12, only one path is allowed. If you use PEM files, you can specify multiple paths.

The relative paths are relative to the application working directly.

Environment variable: QUARKUS_MAILER__MAILER_NAME__TRUSTSTORE_PATHS

Show more

list of string

Sets the trust store type. By default, it guesses the type from the file name extension. For instance, truststore.pem will be seen as a PEM file, while truststore.jks will be seen as a JKS file. truststore.p12 and truststore.pfx will both be seen as PKCS#12 files. Accepted values are: JKS, PEM, PKCS.

Environment variable: QUARKUS_MAILER__MAILER_NAME__TRUSTSTORE_TYPE

Show more

string

Whether the mail should always been sent as multipart even if they don’t have attachments. When sets to true, the mail message will be encoded as multipart even for simple mails without attachments.

Environment variable: QUARKUS_MAILER__MAILER_NAME__MULTI_PART_ONLY

Show more

boolean

false

Sets if sending allows recipients errors. If set to true, the mail will be sent to the recipients that the server accepted, if any.

Environment variable: QUARKUS_MAILER__MAILER_NAME__ALLOW_RCPT_ERRORS

Show more

boolean

false

Enables or disables the pipelining capability if the SMTP server supports it.

Environment variable: QUARKUS_MAILER__MAILER_NAME__PIPELINING

Show more

boolean

true

Sets the connection pool cleaner period. Zero disables expiration checks and connections will remain in the pool until they are closed.

Environment variable: QUARKUS_MAILER__MAILER_NAME__POOL_CLEANER_PERIOD

Show more

Duration

PT1S

Set the keep alive timeout for the SMTP connection. This value determines how long a connection remains unused in the pool before being evicted and closed. A timeout of 0 means there is no timeout.

Environment variable: QUARKUS_MAILER__MAILER_NAME__KEEP_ALIVE_TIMEOUT

Show more

Duration

PT300S

Sets the workstation used on NTLM authentication.

Environment variable: QUARKUS_MAILER__MAILER_NAME__NTLM_WORKSTATION

Show more

string

Sets the domain used on NTLM authentication.

Environment variable: QUARKUS_MAILER__MAILER_NAME__NTLM_DOMAIN

Show more

string

Allows sending emails to these recipients only.

Approved recipients are compiled to a Pattern and must be a valid regular expression. The created Pattern is case-insensitive as emails are case insensitive. Provided patterns are trimmed before being compiled.

Environment variable: QUARKUS_MAILER__MAILER_NAME__APPROVED_RECIPIENTS

Show more

list of Pattern

Log rejected recipients as warnings.

If false, the rejected recipients will be logged at the DEBUG level.

Environment variable: QUARKUS_MAILER__MAILER_NAME__LOG_REJECTED_RECIPIENTS

Show more

boolean

false

期間フォーマットについて

To write duration values, use the standard java.time.Duration format. See the Duration#parse() Java API documentation for more information.

数字で始まる簡略化した書式を使うこともできます:

  • 数値のみの場合は、秒単位の時間を表します。

  • 数値の後に ms が続く場合は、ミリ秒単位の時間を表します。

その他の場合は、簡略化されたフォーマットが解析のために java.time.Duration フォーマットに変換されます:

  • 数値の後に hms が続く場合は、その前に PT が付けられます。

  • 数値の後に d が続く場合は、その前に P が付けられます。

関連コンテンツ

同一エクステンション

同一トピック