Browse Source
We are sucessfully receiving push mails and sending notifications upon receiving emails. Next step: Enable Online configurationdrop_old_mail
Stephan Richter
3 years ago
5 changed files with 28 additions and 14 deletions
@ -1,15 +1,34 @@ |
|||||||
package de.srsoftware.widerhall; |
package de.srsoftware.widerhall; |
||||||
|
|
||||||
|
import org.json.simple.JSONObject; |
||||||
import org.slf4j.Logger; |
import org.slf4j.Logger; |
||||||
import org.slf4j.LoggerFactory; |
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
import javax.mail.Message; |
import javax.mail.Message; |
||||||
import javax.mail.MessagingException; |
import javax.mail.MessagingException; |
||||||
|
import java.io.UnsupportedEncodingException; |
||||||
|
|
||||||
public class Forwarder implements MessageHandler { |
public class Forwarder implements MessageHandler { |
||||||
private static final Logger LOG = LoggerFactory.getLogger(Forwarder.class); |
private static final Logger LOG = LoggerFactory.getLogger(Forwarder.class); |
||||||
|
private final SmtpClient smtp; |
||||||
|
private final JSONObject config; |
||||||
|
|
||||||
|
public Forwarder(JSONObject config) { |
||||||
|
this.config = config; |
||||||
|
SmtpClient smtp = new SmtpClient(config); |
||||||
|
this.smtp = smtp; |
||||||
|
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void onMessageReceived(Message message) throws MessagingException { |
public void onMessageReceived(Message message) throws MessagingException { |
||||||
LOG.debug("forwarding {}",message.getSubject()); |
LOG.debug("forwarding {}",message.getSubject()); |
||||||
|
String testSender = (String) config.get("sender"); |
||||||
|
String testReceiver = (String) config.get("receiver"); |
||||||
|
|
||||||
|
try { |
||||||
|
smtp.send(config,testSender,"Stephan Richter",testReceiver,"Info: "+message.getSubject(),"Neue Mail eingegangen!"); |
||||||
|
} catch (UnsupportedEncodingException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue