1 package com.nilhcem.fakesmtp.server;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import org.subethamail.smtp.helper.SimpleMessageListener;
6
7
8
9
10
11
12
13 public final class MailListener implements SimpleMessageListener {
14 private final MailSaver saver;
15
16
17
18
19
20
21 public MailListener(MailSaver saver) {
22 this.saver = saver;
23 }
24
25
26
27
28
29
30
31
32
33
34
35
36 public boolean accept(String from, String recipient) {
37 return true;
38 }
39
40
41
42
43 @Override
44 public void deliver(String from, String recipient, InputStream data) throws IOException {
45 saver.saveEmailAndNotify(from, recipient, data);
46 }
47 }