I can't send mails from my java quarkus application to mailhog which runs locally.
It's possible to send mails from the windows terminal with Send-MailMessage -From "[email protected]" -To "[email protected]" -Subject "Test Email" -Body "Hello MailHog!" -SmtpServer "localhost" -Port 1025 to mailhog, but as soon as I use java it fails.
I have these application.properties:
quarkus.mailer.host=localhost
quarkus.mailer.port=1025
[email protected]
And this quarkus test:
import io.quarkus.mailer.Mail;
import io.quarkus.mailer.Mailer;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
@QuarkusTest
public class EmailServiceMailHogTest {
@Inject
Mailer mailer;
@Test
void testSendSimpleEmail() {
mailer.send(Mail.withText("[email protected]", "A simple email from quarkus", "This is my body.").setFrom("[email protected]"));
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
It would be great, if someone could help me to make it work :)