mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
Close the session transport
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
This commit is contained in:
parent
d124f52a4b
commit
4e808cd8ca
@ -24,7 +24,6 @@ import javax.mail.Part;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
|
||||
import org.apache.commons.mail.DefaultAuthenticator;
|
||||
import org.apache.commons.mail.Email;
|
||||
import org.apache.commons.mail.EmailException;
|
||||
import org.apache.commons.mail.SimpleEmail;
|
||||
@ -95,7 +94,7 @@ public class SMTPHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
if (!(config.username.isEmpty() || config.password.isEmpty())) {
|
||||
mail.setAuthenticator(new DefaultAuthenticator(config.username, config.password));
|
||||
mail.setAuthentication(config.username, config.password);
|
||||
}
|
||||
|
||||
Session localSession;
|
||||
@ -113,7 +112,15 @@ public class SMTPHandler extends BaseThingHandler {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
session = null;
|
||||
Session localSession = session;
|
||||
if (localSession != null) {
|
||||
try {
|
||||
localSession.getTransport().close();
|
||||
} catch (MessagingException ignore) {
|
||||
}
|
||||
session = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user