diff --git a/.env.example b/.env.example index 544d42adb..f256cf798 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,7 @@ FB_APP_SECRET= FB_APP_ID= #mail - +MAILER_SENDER_EMAIL= SMTP_ADDRESS= SMTP_USERNAME= SMTP_PASSWORD= diff --git a/.rubocop.yml b/.rubocop.yml index d4e88a35b..4246c9f3e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,6 +15,13 @@ Style/SymbolArray: Metrics/BlockLength: Exclude: - spec/**/* + - '**/routes.rb' +Rails/ApplicationController: + Exclude: + - 'app/controllers/api/v1/widget/messages_controller.rb' + - 'app/controllers/dashboard_controller.rb' + - 'app/controllers/widget_tests_controller.rb' + - 'app/controllers/widgets_controller.rb' Style/ClassAndModuleChildren: EnforcedStyle: compact RSpec/NestedGroups: diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 56af56186..b4715b0af 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,5 @@ class ApplicationMailer < ActionMailer::Base - default from: 'accounts@chatwoot.com' + default from: ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com') layout 'mailer' # helpers diff --git a/app/mailers/assignment_mailer.rb b/app/mailers/assignment_mailer.rb index 1584c63ed..5ba9f874d 100644 --- a/app/mailers/assignment_mailer.rb +++ b/app/mailers/assignment_mailer.rb @@ -1,5 +1,5 @@ class AssignmentMailer < ApplicationMailer - default from: 'accounts@chatwoot.com' + default from: ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com') layout 'mailer' def conversation_assigned(conversation, agent) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index e6d00aea2..ce0010637 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -12,7 +12,7 @@ Devise.setup do |config| # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = 'accounts@chatwoot.com' + config.mailer_sender = ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com') # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' diff --git a/docs/development/project-setup/environment-variables.md b/docs/development/project-setup/environment-variables.md index 7e9952a14..2c08f5200 100644 --- a/docs/development/project-setup/environment-variables.md +++ b/docs/development/project-setup/environment-variables.md @@ -35,6 +35,7 @@ For development, you don't need an email provider. Chatwoot uses [letter-opener] For production use, use the following variables to set SMTP server. ```bash +MAILER_SENDER_EMAIL= SMTP_ADDRESS= SMTP_USERNAME= SMTP_PASSWORD= diff --git a/spec/mailers/confirmation_instructions_spec.rb b/spec/mailers/confirmation_instructions_spec.rb index 214175273..32e5aa915 100644 --- a/spec/mailers/confirmation_instructions_spec.rb +++ b/spec/mailers/confirmation_instructions_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Confirmation Instructions', type: :mailer do end it 'uses the user\'s name' do - expect(mail.body).to match("Welcome, #{confirmable_user.name}!") + expect(mail.body).to match("Welcome, #{CGI.escapeHTML(confirmable_user.name)}!") end it 'does not refer to the inviter and their account' do