https://github.com/quarkiverse/quarkus-mailpit
Email and SMTP testing tool with API for developers
https://github.com/quarkiverse/quarkus-mailpit
email quarkus-extension smtp-server
Last synced: about 1 year ago
JSON representation
Email and SMTP testing tool with API for developers
- Host: GitHub
- URL: https://github.com/quarkiverse/quarkus-mailpit
- Owner: quarkiverse
- License: apache-2.0
- Created: 2023-10-13T18:20:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T17:07:48.000Z (about 1 year ago)
- Last Synced: 2025-04-10T18:49:10.123Z (about 1 year ago)
- Topics: email, quarkus-extension, smtp-server
- Language: Java
- Homepage: https://github.com/axllent/mailpit
- Size: 783 KB
- Stars: 19
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README


# Quarkus Mailpit
[](https://search.maven.org/artifact/io.quarkiverse.mailpit/quarkus-mailpit)
[](https://opensource.org/licenses/Apache-2.0)
[](https://github.com/quarkiverse/quarkus-mailpit/actions/workflows/build.yml)
A Quarkus extension that lets you utilize [Mailpit](https://github.com/axllent/mailpit) as a [DevService](https://quarkus.io/guides/dev-services) for the Quarkus Mailer enabling zero-config SMTP for testing or running in dev mode. Mailpit acts as an SMTP server, provides a modern web interface to view & test captured emails, and contains an API for automated integration testing.
Using this service has some obvious advantages when running in dev mode including but not limited to:
* Verify e-mail and their content without a real mail server
* Prevent accidentally sending a customer an email while developing
* Use the REST API to verify contents of real send emails and not mocked mail
* [12 Factor App: Backing services](https://12factor.net/backing-services) Treat backing services as attached resources
* [12 Factor App: Dev/Prod Parity](https://12factor.net/dev-prod-parity) Keep development and production as similar as possible
## Getting started
Read the full [Mailpit documentation](https://docs.quarkiverse.io/quarkus-mailpit/dev/index.html).
### Prerequisite
- Create or use an existing Quarkus application which uses Mailer
- Add the Mailpit extension
### Installation
Create a new mailpit project (with a base mailpit starter code):
- With [code.quarkus.io](https://code.quarkus.io/?a=mailpit-bowl&j=17&e=io.quarkiverse.mailpit%3Aquarkus-mailpit)
- With the [Quarkus CLI](https://quarkus.io/guides/cli-tooling):
```bash
quarkus create app mailpit-app -x=io.quarkiverse.mailpit:quarkus-mailpit
```
Or add to you pom.xml directly:
```xml
io.quarkiverse.mailpit
quarkus-mailpit
{project-version}
io.quarkiverse.mailpit
quarkus-mailpit-testing
{project-version}
test
```
## Usage
Mailpit configure automatically all mailer configuration (even `MailerName`).
```java
@Path("/superheroes")
@ApplicationScoped
public class SuperheroResource {
@Inject
Mailer mailer;
@GET
public String villainAlert() {
Mail m = new Mail();
m.setFrom("admin@hallofjustice.net");
m.setTo(List.of("superheroes@quarkus.io"));
m.setSubject("WARNING: Super Villain Alert");
m.setText("Lex Luthor has been seen in Gotham City!");
mailer.send(m);
return "Superheroes alerted!";
}
}
```
Then inspect your e-mails from your running application in the Dev UI:

## Logging
You can view all of Mailpit's container logs right in the DevUI log area to debug all messages and errors from Mailpit.

## Testing
Running your integration tests you can inspect the results of any mail capture by Mailpit using our test framework. For example to test the example email above the test would look like this:
```java
@QuarkusTest
@WithMailbox
public class MailpitResourceTest {
@InjectMailbox
Mailbox mailbox;
@AfterEach
public void afterEach() throws ApiException {
// clear the mailbox after each test run if you prefer
mailbox.clear();
}
@Test
public void testAlert() throws ApiException {
given()
.when().get("/mailpit/alert")
.then()
.statusCode(200)
.body(is("Superheroes alerted!!"));
// look up the mail and assert it
Message message = mailbox.findFirst("admin@hallofjustice.net");
assertThat(message, notNullValue());
assertThat(message.getTo().get(0).getAddress(), is("superheroes@quarkus.io"));
assertThat(message.getSubject(), is("WARNING: Super Villain Alert"));
assertThat(message.getText(), is("Lex Luthor has been seen in Gotham City!\r\n"));
}
}
```
## π§βπ» Contributing
- Contribution is the best way to support and get involved in community!
- Please, consult our [Code of Conduct](./CODE_OF_CONDUCT.md) policies for interacting in our community.
- Contributions to `quarkus-mailpit` Please check our [CONTRIBUTING.md](./CONTRIBUTING.md)
### If you have any idea or question π€·
- [Ask a question](https://github.com/quarkiverse/quarkus-mailpit/discussions)
- [Raise an issue](https://github.com/quarkiverse/quarkus-mailpit/issues)
- [Feature request](https://github.com/quarkiverse/quarkus-mailpit/issues)
- [Code submission](https://github.com/quarkiverse/quarkus-mailpit/pulls)
## Contributors β¨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Melloware
π» π§

tmulle
β οΈ π

wansors
π

George Gastaldi
π β οΈ π

Eric Kloss
π

Geoffrey GREBERT
π» π¨

Georg Leber
π

Max Rydahl Andersen
π

Phillip KrΓΌger
π»

horst-laubenthal
π€

Eric Deandrea
π€ π»

Georgios Andrianakis
π»

carolosf
π»

Ralph Slooten
π»

Damien ClΓ©ment d'Huart
π

Yoav Geva
π€