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.
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 theMailServer
initialises the GreenMail server with a hardcoded host value ofnull
, the CitrusMailServer
will only bind to the loopback interface and not receive Mails from another interfaces. This can be fixed by adding a host method to theMailServerBuilder
and setting the host value instead ofnull
for the GreenMail initialisation in the MailServer startup() functionOn a side note: it also seems that if you use the
smtp(GreenMail smtpServer)
method from theMailServerBuilder
, the given GreenMail server is overwritten in the MailServer startup() function as there is a missing null check before initialising a new GreenMail instance.