Mailer Reference Guide
本指南是 Mailer Getting Started Guide 的配套文档。它更详细地说明了 Quarkus Mailer 的配置和用法。
This guide is the companion from the Mailer Getting Started Guide. It explains in more details the configuration and usage of the Quarkus Mailer.
Mailer extension
若要使用邮件服务,您需要添加 `quarkus-mailer`扩展。
To use the mailer, you need to add the quarkus-mailer
extension.
你可以使用以下方式将扩展添加到你的项目:
You can add the extension to your project using:
> ./mvnw quarkus:add-extensions -Dextensions="mailer"
或者只需将以下依赖项添加到你的项目中:
Or just add the following dependency to your project:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mailer</artifactId>
</dependency>
Accessing the mailer
您可以使用以下方法在应用程序中注入发送器:
You can inject the mailer in your application using:
@Inject
Mailer mailer;
@Inject
ReactiveMailer reactiveMailer;
有 2 个 API:
There are 2 APIs:
-
io.quarkus.mailer.Mailer
provides the imperative (blocking and synchronous) API; -
io.quarkus.mailer.reactive.ReactiveMailer
provides the reactive (non-blocking and asynchronous) API
这两个 API 在功能上是等效的。事实上,`Mailer`实现构建在 `ReactiveMailer`实现之上。 |
The two APIs are equivalent feature-wise. Actually the |
Deprecation
`io.quarkus.mailer.ReactiveMailer`已弃用,被 `io.quarkus.mailer.reactive.ReactiveMailer`所取代。
|
如要发送一封简单电子邮件,请按以下步骤操作:
To send a simple email, proceed as follows:
// 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."));
例如,您可以在 HTTP 端点中使用 `Mailer`如下所示:
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"));
}
@GET
@Path("/reactive")
public Uni<Void> sendASimpleEmailAsync() {
return reactiveMailer.send(
Mail.withText("to@acme.org", "A reactive email from quarkus", "This is my body"));
}
Creating Mail objects
发送器可让您发送 `io.quarkus.mailer.Mail`对象。您可以从构造函数或 `Mail.withText`和 `Mail.withHtml`帮助程序方法创建新 `io.quarkus.mailer.Mail`实例。`Mail`实例可让您添加收件人(to、cc 或 bcc)、设置主题、标头、发件人(from)地址……
The mailer lets you send io.quarkus.mailer.Mail
objects.
You can create new io.quarkus.mailer.Mail
instances from the constructor or from the Mail.withText
and
Mail.withHtml
helper methods.
The Mail
instance lets you add recipients (to, cc, or bcc), set the subject, headers, sender (from) address…
您还可以一次发送多个 `Mail`对象:
You can also send several Mail
objects in one call:
mailer.send(mail1, mail2, mail3);
Sending attachments
要发送附件,只需在 `io.quarkus.mailer.Mail`实例上使用 `addAttachment`方法:
To send attachments, just use the addAttachment
methods on the io.quarkus.mailer.Mail
instance:
@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")
);
}
附件可以从原始字节(如代码段中所示)或文件创建。请注意,文件的解析是基于应用程序的工作目录。
Attachments can be created from raw bytes (as shown in the snippet) or files. Note that files are resolved from the working directory of the application.
Sending HTML emails with inlined attachments
发送 HTML 电子邮件时,您可以在其中添加内联附件。例如,您可以随电子邮件发送图片,图片将显示在邮件内容中。如果您将图片文件放入 `META-INF/resources`文件夹,您应该指定文件的完整路径,e.g.`META-INF/resources/quarkus-logo.png`否则,Quarkus 会在根目录中查找该文件。
When sending HTML emails, you can add inlined attachments.
For example, you can send an image with your email, and this image will be displayed in the mail content.
If you put the image file into the META-INF/resources
folder, you should specify the full path to the file, e.g. META-INF/resources/quarkus-logo.png
otherwise Quarkus will look for the file in the root directory.
@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_的格式和引用。根据规范,创建内联附件时,内容 ID 必须按以下格式构建: <id@domain>
。如果您不将内容 ID 包含在 <>`之间,它会自动为您进行包装。当您想要引用附件时,比如在 `src`属性中,请使用 `cid:id@domain
(不含 <`和 `>
)。
Note the content-id format and reference.
By spec, when you create the inline attachment, the content-id must be structured as follows: <id@domain>
.
If you don’t wrap your content-id between <>
, it is automatically wrapped for you.
When you want to reference your attachment, for instance in the src
attribute, use cid:id@domain
(without the <
and >
).
Message Body Based on Qute Templates
还可以使用 Qute templates自动创建消息正文,从而发送电子邮件。
It’s also possible to send an e-mail where the message body is created automatically using Qute templates.
您可以在 Java 代码中定义类型安全邮件模板。只要用 `@io.quarkus.qute.CheckedTemplate`注释一个类,该类中的所有返回 `MailTemplate`的 `static native`方法都将用于定义类型安全邮件模板及它们需要的参数列表:
You can define a type-safe mail template in your Java code.
Just annotate a class with @io.quarkus.qute.CheckedTemplate
and all its static native
methods that return MailTemplate
will be used to define type-safe mail templates and the list of parameters they require:
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 | By convention, the enclosing class name and method names are used to locate the template. In this particular case,
we will use the src/main/resources/templates/MailingResource/hello.html and src/main/resources/templates/MailingResource/hello.txt templates to create the message body. |
2 | Set the data used in the template. |
3 | Create a mail template instance and set the recipient. |
4 | MailTemplate.send() triggers the rendering and, once finished, sends the e-mail via a Mailer instance. |
或者,使用一个实现 `io.quarkus.mailer.MailTemplate`的 Java 记录。记录组件表示模板参数。
Alternatively, use a Java record that implements io.quarkus.mailer.MailTemplate
.
The record components represent the template parameters.
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 | By convention, the enclosing class name and the record name are used to locate the template. In this particular case,
we will use the src/main/resources/templates/MailingResource/hello.html and src/main/resources/templates/MailingResource/hello.txt templates to create the message body. |
2 | Set the data used in the template. |
3 | Create a mail template instance and set the recipient. |
4 | MailTemplate.send() triggers the rendering and, once finished, sends the e-mail via a Mailer instance. |
还可以不使用类型安全模板执行此操作:
You can also do this without type-safe templates:
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 | If there is no @Location qualifier provided, the field name is used to locate the template.
Otherwise, search for the template as the specified location. In this particular case, we will use the src/main/resources/templates/hello.html and src/main/resources/templates/hello.txt templates to create the message body. |
2 | Create a mail template instance and set the recipient. |
3 | Set the data used in the template. |
4 | MailTemplate.send() triggers the rendering and, once finished, sends the e-mail via a Mailer instance. |
注入的邮件模板会在构建期间得到验证。如果在 `src/main/resources/templates`中没有匹配的模板,则构建将失败。 |
Injected mail templates are validated during build.
The build fails if there is no matching template in |
Execution model
反应型发送器是无阻塞的,结果将提供在一个 I/O 线程上。请参阅 Quarkus Reactive Architecture documentation以了解此主题的更多详细信息。
The reactive mailer is non-blocking, and the results are provided on an I/O thread. See the Quarkus Reactive Architecture documentation for further details on this topic.
非反应型发送器会阻塞直到消息发送到 SMTP 服务器。请注意,这并不意味着消息已被发送,而只是将其成功发送到了 SMTP 服务器,SMTP 服务器将负责发送。
The non-reactive mailer blocks until the messages are sent to the SMTP server. Note that does not mean that the message is delivered, just that it’s been sent successfully to the SMTP server, which will be responsible for the delivery.
Testing email sending
由于在开发和测试过程中发送电子邮件非常不方便,因此可以将 quarkus.mailer.mock`布尔值配置设置为 `true
,以防止实际发送电子邮件,而是将它们打印到 stdout 并将它们收集到 `MockMailbox`bean 中。如果您在 dev 或 test 模式下运行 Quarkus,则这是默认设置。
Because it is very inconvenient to send emails during development and testing, you can set the quarkus.mailer.mock
boolean
configuration to true
to prevent the actual sending of emails but instead print them on stdout and collect them in a MockMailbox
bean instead.
This is the default if you are running Quarkus in dev or test mode.
然后,可以编写测试以验证您的电子邮件是否已发送,例如,通过 REST 端点:
You can then write tests to verify that your emails were sent, for example, by a REST endpoint:
@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扩展,该扩展为 Mailpit提供开发服务,这是一个用于测试和调试电子邮件发送的漂亮界面。
Another option is to use the Quarkus Mailpit extension which provides Dev Services for Mailpit, a nice UI for testing and debugging email sending.
Using the underlying Vert.x Mail Client
Quarkus Mailer 是在 Vert.x Mail Client基础上实现的,它提供了一种异步和无阻塞的方式来发送电子邮件。如果您需要对发送邮件的方式进行精细控制,例如,如果您需要检索消息 ID,您可以注入底层客户端并直接使用它:
The Quarkus Mailer is implemented on top of the Vert.x Mail Client, providing an asynchronous and non-blocking way to send emails. If you need fine control on how the mail is sent, for instance if you need to retrieve the message ids, you can inject the underlying client, and use it directly:
@Inject MailClient client;
公开了三种 API 风格:
Three API flavors are exposed:
-
the Mutiny client (
io.vertx.mutiny.ext.mail.MailClient
) -
the bare client (
io.vertx.ext.mail.MailClient
)
查看 Using Vert.x guide以了解有关这些不同 API 以及如何选择最适合您的 API 的更多详细信息。
Check the Using Vert.x guide for further details about these different APIs and how to select the most suitable for you.
检索到的 `MailClient`使用上面介绍的配置属性进行配置。您还可以创建自己的实例并传递自己的配置。
The retrieved MailClient
is configured using the configuration property presented above.
You can also create your own instance, and pass your own configuration.
Using SSL with native executables
请注意,如果您为发送器启用了 SSL 并且您要构建一个本机可执行文件,则您需要启用 SSL 支持。请参阅 Using SSL With Native Executables指南以获取更多信息。
Note that if you enable SSL for the mailer and you want to build a native executable, you will need to enable the SSL support. Please refer to the Using SSL With Native Executables guide for more information.
Configuring the SMTP credentials
建议对任何敏感数据进行加密,例如 quarkus.mailer.password
。一种方法是将值保存到一个安全的存储中,例如 HashiCorp Vault,并从配置中引用它。假设 Vault 中在路径 myapps/myapp/myconfig`包含键 `mail-password
,那么邮件扩展可以简单地配置为:
It is recommended to encrypt any sensitive data, such as the quarkus.mailer.password
.
One approach is to save the value into a secure store like HashiCorp Vault, and refer to it from the configuration.
Assuming for instance that Vault contains key mail-password
at path myapps/myapp/myconfig
, then the mailer
extension can be simply configured as:
...
# 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
,获取新值的唯一方法是重新启动应用程序。
Please note that the password value is evaluated only once, at startup time. If mail-password
was changed in Vault,
the only way to get the new value would be to restart the application.
请使用 Vault,您需要 Quarkus Vault扩展。可以在 extension documentation中找到有关此扩展及其配置的更多详细信息。 |
Do use Vault, you need the Quarkus Vault extension. More details about this extension and its configuration can be found in the extension documentation. |
有关 Mailer 配置的更多信息,请参阅 Configuration Reference。 |
For more information about the Mailer configuration please refer to the configuration-reference. |
Configuring TLS
SMTP 提供了多种使用 TLS 的方法:
SMTP provides various way to use TLS:
-
StartTLS: The client connects to the server using a plain connection and then upgrades to a secure connection.
-
SSL/TLS: The client connects to the server using a secure connection from the start.
Configuring STARTTLS
要使用 STARTTLS
,您需要将 start-tls
属性配置为 REQUIRED
或 OPTIONAL
,并将 tls
设置为 false
:
To use STARTTLS
, you need to configure the start-tls
property to REQUIRED
or OPTIONAL
and set tls
to false
:
quarkus.mailer.tls=false
quarkus.mailer.start-tls=REQUIRED
将 tls
设置为 false
可确保我们使用纯连接进行连接,然后使用 STARTTLS
升级到安全连接。
Setting tls
to false
ensure we connect using a plain connection and then upgrade to a secure connection using STARTTLS
.
要配置信任库,您可以使用存储在 TLS registry 中的 named TLS 配置:
To configure the trust store, you can use a named TLS configuration stored in the TLS registry:
quarkus.mailer.tls=false
quarkus.mailer.start-tls=REQUIRED
quarkus.mailer.tls-configuration-name=my-mailer # Reference the named configuration
quarkus.tls.my-mailer.trust-store.pem.certs=server-cert.pem # Configure the trust store
虽然不建议,但您可以通过将 quarkus.tls.trust-all
设为 true
来信任所有证书:
While not recommended, you can trust all certificates by setting quarkus.tls.trust-all
to true
:
quarkus.mailer.tls=false
quarkus.mailer.start-tls=REQUIRED
quarkus.mailer.tls-configuration-name=my-mailer # Reference the named configuration
quarkus.tls.my-mailer.trust-all=true
其他方法是,可以使用 deprecated quarkus.mailer.trust-store.paths
和 quarkus.mailer.trust-all
属性:
Alternatively, you can use the deprecated quarkus.mailer.trust-store.paths
and quarkus.mailer.trust-all
properties:
quarkus.mailer.tls=false
quarkus.mailer.start-tls=REQUIRED
quarkus.mailer.truststore.paths=target/certs/mailpit-ca.crt
quarkus.mailer.tls=false
quarkus.mailer.start-tls=REQUIRED
quarkus.mailer.trust-all=true
要使用 START_TLS
,请确保将 tls
设置为 false
,并设置 start-tls
为 REQUIRED
或 OPTIONAL
。
To use START_TLS
, make sure you set tls
to false
and start-tls
to REQUIRED
or OPTIONAL
.
Configuring SSL/TLS
要建立一个 TLS 连接,您需要使用 TLS registry 配置一个 named 配置:
To establish a TLS connection, you need to configure a named configuration using the TLS registry:
quarkus.tls.my-mailer.trust-store.p12.path=server-truststore.p12
quarkus.tls.my-mailer.trust-store.p12.password=secret
quarkus.mailer.tls-configuration-name=my-mailer # Reference the named configuration
在使用邮件发送器时,必须使用 named 配置以避免与其他 TLS 配置发生冲突。邮件发送器不会使用默认的 TLS 配置。
When using the mailer, using a named configuration is required to avoid conflicts with other TLS configurations. The mailer will not use the default TLS configuration.
在配置 named TLS 配置时,TLS 默认启用。如果您的 SMTP 服务器使用的是有效的(受信任的)证书,因此不需要特定的 TLS 配置,则需要显式启用 TLS(因为您不必配置信任存储):
When you configure a named TLS configuration, TLS is enabled by default. If your SMTP server uses a valid (trusted) certificate, and thus do not require a specific TLS configuration, you need to enable TLS explicitly (as you do not have to configure a trust store):
quarkus.mailer.tls=true
当 quarkus.tls.trust-all
设置为 true
时,信任存储配置会被忽略。这在生产环境中是不建议使用的。此外,我们建议您避免使用 quarkus.tls.trust-all
,而是在需要使用 trust-all
时使用命名配置:
When quarkus.tls.trust-all
is set to true
, the trust store configuration is ignored. This is not recommended for production.
Also, we recommend avoiding using quarkus.tls.trust-all
, and use a named configuration instead if trust-all
is required:
quarkus.tls.my-mailer.trust-all=true
quarkus.mailer.tls-configuration-name=my-mailer # Reference the named configuration
您还可以使用已弃用的 quarkus.mailer.trust-all=true
属性。
You can also use the deprecated quarkus.mailer.trust-all=true
property.
Multiple mailer configurations
某些应用程序需要通过不同的 SMTP 服务器发送邮件。
Some applications require to send mails through different SMTP servers.
Quarkus 完全支持此用例,您还可以配置多个邮件程序:
This use case is perfectly supported in Quarkus and you can configure several mailers:
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 | Configuration for the default mailer. |
2 | Configuration for a mailer named aws . |
3 | Configuration for a mailer named sendgrid . |
然后,使用 `@MailerName`CDI 限定符访问命名的邮件发送器:
Then, access your named mailers by using the @MailerName
CDI qualifier:
@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 | Inject instances without qualifier for the default configuration. |
2 | Inject instances with the @MailerName("aws") qualifier for the aws configuration. |
3 | Inject instances with the @MailerName("sendgrid") qualifier for the sendgrid configuration. |
当前仅为默认邮件发送器配置支持使用 @CheckedTemplate
的安全类型模板。
Type-safe template using @CheckedTemplate
are currently only supported for the default mailer configuration.
对命名邮件发送器配置使用 MailTemplate
注入。
Use MailTemplate
injection for the named mailer configurations.
Mailer configuration for popular email services
本节提供与常用邮件服务配对使用的配置。
This section provides the configurations to use with popular mail services.
Gmail specific configuration
如果你想使用 Gmail SMTP 服务器,首先在 Google Account > Security > App passwords
创建一个专门的密码或转到 [role="bare"][role="bare"]https://myaccount.google.com/apppasswords。
If you want to use the Gmail SMTP server, first create a dedicated password in Google Account > Security > App passwords
or go to [role="bare"]https://myaccount.google.com/apppasswords.
你需要在 [role="bare"][role="bare"]https://myaccount.google.com/security 开启两步验证,才能访问应用密码页面。 You need to switch on 2-Step Verification at [role="bare"]https://myaccount.google.com/security in order to access the App passwords page. |
完成后,可以通过将以下属性添加到你的 application.properties
来配置 Quarkus 应用程序:
When done, you can configure your Quarkus application by adding the following properties to your application.properties
:
使用 STARTTLS
:
With STARTTLS
:
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
或者使用 TLS/SSL:
Or with TLS/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.tls=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 邮件发送器需要 The |
AWS SES - Simple Email Service
Prerequisites
-
SES Identity Check, follow the process to setup the DKIM verification
-
Retrieve SMTP endpoint from [role="bare"]https://us-east-1.console.aws.amazon.com/ses/home, example:
email-smtp.us-east-1.amazonaws.com
-
Create SMTP credentials if needed
-
If you are in a sandbox, also verify the recipients (using email verification)
Configuration
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.tls=false
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 服务器发送电子邮件。
The mailjet integration is used on an SMTP relay. You are going to send the email using this SMTP server.
Prerequisites
-
Create a mailJet account and the API key / Secret Key
-
The sender address must be verified (SPF + DKIM) and the email explicitly added to the verified list
Configuration
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.tls=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
Configuration
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.login=REQUIRED
quarkus.mailer.from=...
quarkus.mailer.tls=true
quarkus.mailer.mock=false # In dev mode, prevent from using the mock SMTP server