From 9b5eb98c5924201a3aae8e98c62b20b63284eb24 Mon Sep 17 00:00:00 2001 From: "Aswin Dev P.S" Date: Mon, 11 Apr 2022 15:43:05 +0530 Subject: [PATCH] feat: Support additional authentication mechanisms for SMTP (#4431) * Support additional authentication mechanisms for SMTP --- app/helpers/api/v1/inboxes_helper.rb | 6 +++- .../dashboard/i18n/locale/en/inboxMgmt.json | 3 +- .../dashboard/settings/inbox/SmtpSettings.vue | 23 +++++++++++++++ app/models/channel/email.rb | 2 +- app/views/api/v1/models/_inbox.json.jbuilder | 1 + .../v1/accounts/inboxes_controller_spec.rb | 28 +++++++++++++++++++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/app/helpers/api/v1/inboxes_helper.rb b/app/helpers/api/v1/inboxes_helper.rb index 8cdf8d987..7f3b68953 100644 --- a/app/helpers/api/v1/inboxes_helper.rb +++ b/app/helpers/api/v1/inboxes_helper.rb @@ -29,8 +29,12 @@ module Api::V1::InboxesHelper smtp = Net::SMTP.new(channel_data[:smtp_address], channel_data[:smtp_port]) set_smtp_encryption(channel_data, smtp) + check_smtp_connection(channel_data, smtp) + end - smtp.start(channel_data[:smtp_domain], channel_data[:smtp_email], channel_data[:smtp_password], :login) + def check_smtp_connection(channel_data, smtp) + smtp.start(channel_data[:smtp_domain], channel_data[:smtp_email], channel_data[:smtp_password], + channel_data[:smtp_authentication]&.to_sym || :login) smtp.finish unless smtp&.nil? end diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index bf2652e09..b2a054ebc 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -529,7 +529,8 @@ "ENCRYPTION": "Encryption", "SSL_TLS": "SSL/TLS", "START_TLS": "STARTTLS", - "OPEN_SSL_VERIFY_MODE": "Open SSL Verify Mode" + "OPEN_SSL_VERIFY_MODE": "Open SSL Verify Mode", + "AUTH_MECHANISM": "Authentication" }, "NOTE": "Note: " } diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue index 21a8955ef..92b9a5446 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue @@ -69,6 +69,13 @@ :options="openSSLVerifyModes" :action="handleSSLModeChange" /> +