From 86d6ae5ee0cd42a00339e71a8e6daedf58848356 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 4 Aug 2016 03:25:12 +0200 Subject: 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. --- src/mail/mailer.vala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') 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 != "") { -- cgit v1.2.3