Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Citrus 4: MailServer only binds to loopback interface #1199

Closed
ghost opened this issue Aug 13, 2024 · 1 comment · Fixed by #1209
Closed

Citrus 4: MailServer only binds to loopback interface #1199

ghost opened this issue Aug 13, 2024 · 1 comment · Fixed by #1209

Comments

@ghost
Copy link

ghost commented Aug 13, 2024

Citrus Version
4.x

Expected behavior
Mailserver binds to all interfaces, as in Citrus 3.x, or host is configurable

Actual behavior
Mailserver binds to loopback interface only and the host is not configurable

Test case sample
SMTP interception on a host which has its mail port bound to a non loopback interface. Upgrade from Citrus 3.x to 4.x.

When we upgraded from Citrus 3 to Citrus 4, our mail tests did not work anymore. The problem was due to the default behaviour of subethasmtp vs. GreenMail. In subethasmtp, when no host is given, the mail server binds to all interfaces, whereas GreenMail will bind only to loopback per default.

As the Citrus MailServerBuilder does not have functions to set the host manually, and the MailServer initialises the GreenMail server with a hardcoded host value of null, the Citrus MailServer will only bind to the loopback interface and not receive Mails from another interfaces. This can be fixed by adding a host method to the MailServerBuilder and setting the host value instead of null for the GreenMail initialisation in the MailServer startup() function

On a side note: it also seems that if you use the smtp(GreenMail smtpServer) method from the MailServerBuilder, the given GreenMail server is overwritten in the MailServer startup() function as there is a missing null check before initialising a new GreenMail instance.

@bbortt
Copy link
Collaborator

bbortt commented Aug 14, 2024

thanks for the report! definitely two bugs:

  • binding to other network interfaces, not only loopback
  • use existing mailserver when initialized from builder (null-check)

do you want to work on these and submit a PR or should I try and fix it if I find some time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant