I'm trying to integrate Dumbster to test our JavaMail based notifier for outgoing emails. The emails get sent but in my test Dumbster does not pick them up. I'm not sure if I need additional configuration to make this work buton the dumbster homepage it says, it will listen automatically for mail sent through smtp on port 25.
This is our java mail setup:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.somewhere.com" />
<property name="port" value="25" />
<property name="username" value="theUserName" />
<property name="password" value="thePassword" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>
Our Mailer class just injects the JavaMailer:
@Component
public class OurMailer {
@Inject
private MailSender mailSender;
public void sendMail(String from, String to, String subject, String msg) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(msg);
mailSender.send(message);
}
The test is quite straight forward as they demonstrate on their page:
@Inject
private OurMailer ourMailer;
@Test
public void ourMailer_should_send_mail() {
SimpleSmtpServer server = SimpleSmtpServer.start();
ourMailer.sendMail(FROM_EMAIL, TO_EMAIL, SUBJECT, MESSAGE);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
}
As I said, the mail gets sent but the Assert fails.
Any ideas?
BTW: I also tried Greenmail but with the same result:
maven slightly different:
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.3.1b</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
The test
GreenMail greenMail = new GreenMail(); //uses test ports by default
greenMail.start();
// send mail
Assert.assertEquals("subject", greenMail.getReceivedMessages()[0].getSubject());
greenMail.stop();