diff --git a/app/javascript/shared/store/globalConfig.js b/app/javascript/shared/store/globalConfig.js
index c1786238b..ed33166ae 100644
--- a/app/javascript/shared/store/globalConfig.js
+++ b/app/javascript/shared/store/globalConfig.js
@@ -15,6 +15,7 @@ const {
MAXIMUM_FILE_UPLOAD_SIZE: maximumFileUploadSize,
HCAPTCHA_SITE_KEY: hCaptchaSiteKey,
INSTALLATION_NAME: installationName,
+ INBOUND_EMAIL_DOMAIN_PRESENT: inboundEmailDomainPresent,
LOGO_THUMBNAIL: logoThumbnail,
LOGO: logo,
LOGO_DARK: logoDark,
@@ -43,6 +44,7 @@ const state = {
maximumFileUploadSize: resolveMaximumFileUploadSize(maximumFileUploadSize),
hCaptchaSiteKey,
installationName,
+ inboundEmailDomainPresent: parseBoolean(inboundEmailDomainPresent),
logo,
logoDark,
logoThumbnail,
diff --git a/app/views/api/v1/models/_inbox.json.jbuilder b/app/views/api/v1/models/_inbox.json.jbuilder
index 0ae0745cd..9ec47d858 100644
--- a/app/views/api/v1/models/_inbox.json.jbuilder
+++ b/app/views/api/v1/models/_inbox.json.jbuilder
@@ -79,8 +79,8 @@ end
if resource.email?
## Email Channel Attributes
json.email resource.channel.try(:email)
- json.forwarding_enabled ENV.fetch('MAILER_INBOUND_EMAIL_DOMAIN', '').present?
- json.forward_to_email resource.channel.try(:forward_to_email) if ENV.fetch('MAILER_INBOUND_EMAIL_DOMAIN', '').present?
+ json.forwarding_enabled resource.account.inbound_email_domain.present?
+ json.forward_to_email resource.channel.try(:forward_to_email) if resource.account.inbound_email_domain.present?
## IMAP
if Current.account_user&.administrator?
diff --git a/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb b/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb
index 9e03e2587..a0d352a97 100644
--- a/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb
+++ b/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb
@@ -399,6 +399,40 @@ RSpec.describe 'Inboxes API', type: :request do
expect(response.body).to include('test@test.com')
end
+ it 'creates an email inbox with imap settings and queues the selected import window' do
+ imap_connection = instance_double(Net::IMAP, disconnected?: false)
+
+ allow(Net::IMAP).to receive(:new).and_return(imap_connection)
+ allow(imap_connection).to receive(:login)
+ allow(imap_connection).to receive(:disconnect)
+
+ expect do
+ post "/api/v1/accounts/#{account.id}/inboxes",
+ headers: admin.create_new_auth_token,
+ params: {
+ name: 'Support',
+ imap_fetch_interval: 7,
+ channel: {
+ type: 'email',
+ email: 'support@example.com',
+ imap_enabled: true,
+ imap_address: 'imap.example.com',
+ imap_port: 993,
+ imap_login: 'support@example.com',
+ imap_password: 'imap-password',
+ imap_enable_ssl: true,
+ imap_authentication: 'login'
+ }
+ },
+ as: :json
+ end.to have_enqueued_job(Inboxes::FetchImapEmailsJob).with(a_kind_of(Channel::Email), 7)
+
+ expect(response).to have_http_status(:success)
+ channel = Channel::Email.find_by!(email: 'support@example.com')
+ expect(channel.imap_enabled).to be true
+ expect(channel.smtp_enabled).to be false
+ end
+
it 'creates an api inbox when administrator' do
post "/api/v1/accounts/#{account.id}/inboxes",
headers: admin.create_new_auth_token,