fix: Remove IMAP and SMTP email validation (#4435)
* Remove IMAP and SMTP email validation * Rename imap_email & smtp_email columns to imap_login & smtp_login respectively. * Use channel email domain if inbound email domain not present
This commit is contained in:
@@ -14,7 +14,7 @@ module Api::V1::InboxesHelper
|
||||
Mail.defaults do
|
||||
retriever_method :imap, { address: channel_data[:imap_address],
|
||||
port: channel_data[:imap_port],
|
||||
user_name: channel_data[:imap_email],
|
||||
user_name: channel_data[:imap_login],
|
||||
password: channel_data[:imap_password],
|
||||
enable_ssl: channel_data[:imap_enable_ssl] }
|
||||
end
|
||||
@@ -33,7 +33,7 @@ module Api::V1::InboxesHelper
|
||||
end
|
||||
|
||||
def check_smtp_connection(channel_data, smtp)
|
||||
smtp.start(channel_data[:smtp_domain], channel_data[:smtp_email], channel_data[:smtp_password],
|
||||
smtp.start(channel_data[:smtp_domain], channel_data[:smtp_login], channel_data[:smtp_password],
|
||||
channel_data[:smtp_authentication]&.to_sym || :login)
|
||||
smtp.finish unless smtp&.nil?
|
||||
end
|
||||
|
||||
@@ -486,9 +486,9 @@
|
||||
"LABEL": "Port",
|
||||
"PLACE_HOLDER": "Port"
|
||||
},
|
||||
"EMAIL": {
|
||||
"LABEL": "Email",
|
||||
"PLACE_HOLDER": "Email"
|
||||
"LOGIN": {
|
||||
"LABEL": "Login",
|
||||
"PLACE_HOLDER": "Login"
|
||||
},
|
||||
"PASSWORD": {
|
||||
"LABEL": "Password",
|
||||
@@ -514,9 +514,9 @@
|
||||
"LABEL": "Port",
|
||||
"PLACE_HOLDER": "Port"
|
||||
},
|
||||
"EMAIL": {
|
||||
"LABEL": "Email",
|
||||
"PLACE_HOLDER": "Email"
|
||||
"LOGIN": {
|
||||
"LABEL": "Login",
|
||||
"PLACE_HOLDER": "Login"
|
||||
},
|
||||
"PASSWORD": {
|
||||
"LABEL": "Password",
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
@blur="$v.port.$touch"
|
||||
/>
|
||||
<woot-input
|
||||
v-model="email"
|
||||
:class="{ error: $v.email.$error }"
|
||||
v-model="login"
|
||||
:class="{ error: $v.login.$error }"
|
||||
class="medium-9 columns"
|
||||
:label="$t('INBOX_MGMT.IMAP.EMAIL.LABEL')"
|
||||
:placeholder="$t('INBOX_MGMT.IMAP.EMAIL.PLACE_HOLDER')"
|
||||
@blur="$v.email.$touch"
|
||||
:label="$t('INBOX_MGMT.IMAP.LOGIN.LABEL')"
|
||||
:placeholder="$t('INBOX_MGMT.IMAP.LOGIN.PLACE_HOLDER')"
|
||||
@blur="$v.login.$touch"
|
||||
/>
|
||||
<woot-input
|
||||
v-model="password"
|
||||
@@ -73,7 +73,7 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import SettingsSection from 'dashboard/components/SettingsSection';
|
||||
import { required, minLength, email } from 'vuelidate/lib/validators';
|
||||
import { required, minLength } from 'vuelidate/lib/validators';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
isIMAPEnabled: false,
|
||||
address: '',
|
||||
port: '',
|
||||
email: '',
|
||||
login: '',
|
||||
password: '',
|
||||
isSSLEnabled: true,
|
||||
};
|
||||
@@ -99,7 +99,7 @@ export default {
|
||||
validations: {
|
||||
address: { required },
|
||||
port: { required, minLength: minLength(2) },
|
||||
email: { required, email },
|
||||
login: { required },
|
||||
password: { required },
|
||||
},
|
||||
computed: {
|
||||
@@ -119,14 +119,14 @@ export default {
|
||||
imap_enabled,
|
||||
imap_address,
|
||||
imap_port,
|
||||
imap_email,
|
||||
imap_login,
|
||||
imap_password,
|
||||
imap_enable_ssl,
|
||||
} = this.inbox;
|
||||
this.isIMAPEnabled = imap_enabled;
|
||||
this.address = imap_address;
|
||||
this.port = imap_port;
|
||||
this.email = imap_email;
|
||||
this.login = imap_login;
|
||||
this.password = imap_password;
|
||||
this.isSSLEnabled = imap_enable_ssl;
|
||||
},
|
||||
@@ -140,7 +140,7 @@ export default {
|
||||
imap_enabled: this.isIMAPEnabled,
|
||||
imap_address: this.address,
|
||||
imap_port: this.port,
|
||||
imap_email: this.email,
|
||||
imap_login: this.login,
|
||||
imap_password: this.password,
|
||||
imap_enable_ssl: this.isSSLEnabled,
|
||||
imap_inbox_synced_at: this.isIMAPEnabled
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
@blur="$v.port.$touch"
|
||||
/>
|
||||
<woot-input
|
||||
v-model="email"
|
||||
:class="{ error: $v.email.$error }"
|
||||
v-model="login"
|
||||
:class="{ error: $v.login.$error }"
|
||||
class="medium-9 columns"
|
||||
:label="$t('INBOX_MGMT.SMTP.EMAIL.LABEL')"
|
||||
:placeholder="$t('INBOX_MGMT.SMTP.EMAIL.PLACE_HOLDER')"
|
||||
@blur="$v.email.$touch"
|
||||
:label="$t('INBOX_MGMT.SMTP.LOGIN.LABEL')"
|
||||
:placeholder="$t('INBOX_MGMT.SMTP.LOGIN.PLACE_HOLDER')"
|
||||
@blur="$v.login.$touch"
|
||||
/>
|
||||
<woot-input
|
||||
v-model="password"
|
||||
@@ -91,7 +91,7 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import SettingsSection from 'dashboard/components/SettingsSection';
|
||||
import { required, minLength, email } from 'vuelidate/lib/validators';
|
||||
import { required, minLength } from 'vuelidate/lib/validators';
|
||||
import InputRadioGroup from './components/InputRadioGroup';
|
||||
import SingleSelectDropdown from './components/SingleSelectDropdown';
|
||||
|
||||
@@ -113,7 +113,7 @@ export default {
|
||||
isSMTPEnabled: false,
|
||||
address: '',
|
||||
port: '',
|
||||
email: '',
|
||||
login: '',
|
||||
password: '',
|
||||
domain: '',
|
||||
ssl: false,
|
||||
@@ -147,7 +147,7 @@ export default {
|
||||
required,
|
||||
minLength: minLength(2),
|
||||
},
|
||||
email: { required, email },
|
||||
login: { required },
|
||||
password: { required },
|
||||
domain: { required },
|
||||
},
|
||||
@@ -168,7 +168,7 @@ export default {
|
||||
smtp_enabled,
|
||||
smtp_address,
|
||||
smtp_port,
|
||||
smtp_email,
|
||||
smtp_login,
|
||||
smtp_password,
|
||||
smtp_domain,
|
||||
smtp_enable_starttls_auto,
|
||||
@@ -179,7 +179,7 @@ export default {
|
||||
this.isSMTPEnabled = smtp_enabled;
|
||||
this.address = smtp_address;
|
||||
this.port = smtp_port;
|
||||
this.email = smtp_email;
|
||||
this.login = smtp_login;
|
||||
this.password = smtp_password;
|
||||
this.domain = smtp_domain;
|
||||
this.starttls = smtp_enable_starttls_auto;
|
||||
@@ -220,7 +220,7 @@ export default {
|
||||
smtp_enabled: this.isSMTPEnabled,
|
||||
smtp_address: this.address,
|
||||
smtp_port: this.port,
|
||||
smtp_email: this.email,
|
||||
smtp_login: this.login,
|
||||
smtp_password: this.password,
|
||||
smtp_domain: this.domain,
|
||||
smtp_enable_ssl_tls: this.ssl,
|
||||
|
||||
@@ -26,7 +26,7 @@ class Inboxes::FetchImapEmailsJob < ApplicationJob
|
||||
Mail.defaults do
|
||||
retriever_method :imap, address: channel.imap_address,
|
||||
port: channel.imap_port,
|
||||
user_name: channel.imap_email,
|
||||
user_name: channel.imap_login,
|
||||
password: channel.imap_password,
|
||||
enable_ssl: channel.imap_enable_ssl
|
||||
end
|
||||
|
||||
@@ -128,11 +128,11 @@ class ConversationReplyMailer < ApplicationMailer
|
||||
def custom_message_id
|
||||
last_message = @message || @messages&.last
|
||||
|
||||
"<conversation/#{@conversation.uuid}/messages/#{last_message&.id}@#{@account.inbound_email_domain}>"
|
||||
"<conversation/#{@conversation.uuid}/messages/#{last_message&.id}@#{channel_email_domain}>"
|
||||
end
|
||||
|
||||
def in_reply_to_email
|
||||
conversation_reply_email_id || "<account/#{@account.id}/conversation/#{@conversation.uuid}@#{@account.inbound_email_domain}>"
|
||||
conversation_reply_email_id || "<account/#{@account.id}/conversation/#{@conversation.uuid}@#{channel_email_domain}>"
|
||||
end
|
||||
|
||||
def conversation_reply_email_id
|
||||
|
||||
@@ -26,7 +26,7 @@ module ConversationReplyMailerHelper
|
||||
smtp_settings = {
|
||||
address: @channel.smtp_address,
|
||||
port: @channel.smtp_port,
|
||||
user_name: @channel.smtp_email,
|
||||
user_name: @channel.smtp_login,
|
||||
password: @channel.smtp_password,
|
||||
domain: @channel.smtp_domain,
|
||||
tls: @channel.smtp_enable_ssl_tls,
|
||||
@@ -48,10 +48,18 @@ module ConversationReplyMailerHelper
|
||||
end
|
||||
|
||||
def email_from
|
||||
email_smtp_enabled ? @channel.smtp_email : from_email_with_name
|
||||
email_smtp_enabled ? @channel.email : from_email_with_name
|
||||
end
|
||||
|
||||
def email_reply_to
|
||||
email_imap_enabled ? @channel.imap_email : reply_email
|
||||
email_imap_enabled ? @channel.email : reply_email
|
||||
end
|
||||
|
||||
# Use channel email domain in case of account email domain is not set for custom message_id and in_reply_to
|
||||
def channel_email_domain
|
||||
return @account.inbound_email_domain if @account.inbound_email_domain.present?
|
||||
|
||||
email = @inbox.channel.try(:email)
|
||||
email.present? ? email.split('@').last : raise(StandardError, 'Channel email domain not present.')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
# email :string not null
|
||||
# forward_to_email :string not null
|
||||
# imap_address :string default("")
|
||||
# imap_email :string default("")
|
||||
# imap_enable_ssl :boolean default(TRUE)
|
||||
# imap_enabled :boolean default(FALSE)
|
||||
# imap_inbox_synced_at :datetime
|
||||
# imap_login :string default("")
|
||||
# imap_password :string default("")
|
||||
# imap_port :integer default(0)
|
||||
# smtp_address :string default("")
|
||||
# smtp_authentication :string default("login")
|
||||
# smtp_domain :string default("")
|
||||
# smtp_email :string default("")
|
||||
# smtp_enable_ssl_tls :boolean default(FALSE)
|
||||
# smtp_enable_starttls_auto :boolean default(TRUE)
|
||||
# smtp_enabled :boolean default(FALSE)
|
||||
# smtp_login :string default("")
|
||||
# smtp_openssl_verify_mode :string default("none")
|
||||
# smtp_password :string default("")
|
||||
# smtp_port :integer default(0)
|
||||
@@ -37,8 +37,8 @@ class Channel::Email < ApplicationRecord
|
||||
include Reauthorizable
|
||||
|
||||
self.table_name = 'channel_email'
|
||||
EDITABLE_ATTRS = [:email, :imap_enabled, :imap_email, :imap_password, :imap_address, :imap_port, :imap_enable_ssl, :imap_inbox_synced_at,
|
||||
:smtp_enabled, :smtp_email, :smtp_password, :smtp_address, :smtp_port, :smtp_domain, :smtp_enable_starttls_auto,
|
||||
EDITABLE_ATTRS = [:email, :imap_enabled, :imap_login, :imap_password, :imap_address, :imap_port, :imap_enable_ssl, :imap_inbox_synced_at,
|
||||
:smtp_enabled, :smtp_login, :smtp_password, :smtp_address, :smtp_port, :smtp_domain, :smtp_enable_starttls_auto,
|
||||
:smtp_enable_ssl_tls, :smtp_openssl_verify_mode, :smtp_authentication].freeze
|
||||
|
||||
validates :email, uniqueness: true
|
||||
|
||||
@@ -53,7 +53,7 @@ if resource.email?
|
||||
json.email resource.channel.try(:email)
|
||||
|
||||
## IMAP
|
||||
json.imap_email resource.channel.try(:imap_email)
|
||||
json.imap_login resource.channel.try(:imap_login)
|
||||
json.imap_password resource.channel.try(:imap_password)
|
||||
json.imap_address resource.channel.try(:imap_address)
|
||||
json.imap_port resource.channel.try(:imap_port)
|
||||
@@ -61,7 +61,7 @@ if resource.email?
|
||||
json.imap_enable_ssl resource.channel.try(:imap_enable_ssl)
|
||||
|
||||
## SMTP
|
||||
json.smtp_email resource.channel.try(:smtp_email)
|
||||
json.smtp_login resource.channel.try(:smtp_login)
|
||||
json.smtp_password resource.channel.try(:smtp_password)
|
||||
json.smtp_address resource.channel.try(:smtp_address)
|
||||
json.smtp_port resource.channel.try(:smtp_port)
|
||||
|
||||
Reference in New Issue
Block a user