From afd9f4e278a6a8fa178e30153cce725518893871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Sat, 14 Mar 2020 22:30:50 +0100 Subject: [PATCH] Allow the smtp mechanism to be provided without quotes and all lowercase --- src/mail.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mail.rs b/src/mail.rs index 7a3c6603..699bd156 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -44,10 +44,11 @@ fn mailer() -> SmtpTransport { _ => smtp_client, }; - let smtp_client = match &CONFIG.smtp_auth_mechanism() { - Some(auth_mechanism_json) => { - let auth_mechanism = serde_json::from_str::(&auth_mechanism_json); - match auth_mechanism { + let smtp_client = match CONFIG.smtp_auth_mechanism() { + Some(mechanism) => { + let correct_mechanism = format!("\"{}\"", crate::util::upcase_first(&mechanism.trim_matches('"'))); + + match serde_json::from_str::(&correct_mechanism) { Ok(auth_mechanism) => smtp_client.authentication_mechanism(auth_mechanism), _ => panic!("Failure to parse mechanism. Is it proper Json? Eg. `\"Plain\"` not `Plain`"), }