implemented Exception handling in EMailSender
This commit is contained in:
parent
fbf1700c34
commit
fd184e1248
|
@ -9,16 +9,10 @@ import java.io.IOException;
|
|||
import java.util.TimerTask;
|
||||
|
||||
public class BackgroundTasks extends TimerTask {
|
||||
private final TaskList taskList;
|
||||
private final Garden garden;
|
||||
private final PlantList plantList;
|
||||
private final Notifier notifier;
|
||||
//TODO uncomment: privat final WeatherGardenTaskPlaner weatherGardenTaskPlaner;
|
||||
|
||||
public BackgroundTasks(TaskList taskList, Garden garden, PlantList plantList) {
|
||||
this.taskList = taskList;
|
||||
this.garden = garden;
|
||||
this.plantList = plantList;
|
||||
notifier = new Notifier(taskList, garden, plantList);
|
||||
//TODO uncomment: weatherGardenTaskPlaner = new WeatherGardenTaskPlaner(taskList);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@ package ch.zhaw.gartenverwaltung.backgroundtasks.email;
|
|||
|
||||
import ch.zhaw.gartenverwaltung.Settings;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.ArrayList;
|
||||
|
@ -33,8 +30,12 @@ public class EMailSender {
|
|||
message.setText(text);
|
||||
message.setSentDate(new Date());
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
|
||||
System.out.println("Message is ready: ");
|
||||
Transport.send(message);
|
||||
try{
|
||||
Transport.send(message);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
// TODO logger
|
||||
}
|
||||
}
|
||||
|
||||
private void printMail(String receiver, String subject, String text){
|
||||
|
|
Loading…
Reference in New Issue