diff options
author | Sebastian Reichel <sre@ring0.de> | 2016-08-04 03:25:12 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2016-08-04 03:40:26 +0200 |
commit | 86d6ae5ee0cd42a00339e71a8e6daedf58848356 (patch) | |
tree | ca4f23d73f8a998f9f57cb28610277957cb84451 /src | |
parent | f189228ff497d6c0c4dec38f35ed98fe4fd5214e (diff) | |
download | serial-barcode-scanner-86d6ae5ee0cd42a00339e71a8e6daedf58848356.tar.bz2 |
mailer: support disabling starttls
Connection to a localhost mailserver do not need
TLS encryption, so add support for plaintext
connections. Keep default of enabled TLS.
Diffstat (limited to 'src')
-rw-r--r-- | src/mail/mailer.vala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mail/mailer.vala b/src/mail/mailer.vala index e4b1c6d..4888fe7 100644 --- a/src/mail/mailer.vala +++ b/src/mail/mailer.vala @@ -31,6 +31,7 @@ public class MailerImplementation { string server; string username; string password; + bool starttls; unowned string? callback(out string? buf, int *len) { buf = null; @@ -86,15 +87,24 @@ public class MailerImplementation { password = ""; } + try { + starttls = config.get_boolean("MAIL", "starttls"); + } catch(KeyFileError e) { + starttls = true; + } + /* setup server */ result = session.set_server(server); if(result == 0) throw new IOError.FAILED("could not setup server"); /* Use TLS if possible */ - result = session.starttls_enable(Smtp.StartTlsOption.ENABLED); + if (starttls) + result = session.starttls_enable(Smtp.StartTlsOption.ENABLED); + else + result = session.starttls_enable(Smtp.StartTlsOption.DISABLED); if(result == 0) - throw new IOError.FAILED("could not setup TLS"); + throw new IOError.FAILED("could not configure STARTTLS"); /* setup authentication */ if(username != "") { |