Merge pull request #6716 from Haixing-Hu/support-ssl-smtp

Add the support of SSL smtp server

[ci skip]
pull/6717/head
Oliver Günther 6 years ago committed by GitHub
commit 521a1a66ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/views/settings/_notifications.html.erb
  2. 12
      config/configuration.yml.example
  3. 5
      config/locales/crowdin/zh.yml
  4. 1
      config/locales/en.yml
  5. 3
      config/settings.yml
  6. 1
      lib/open_project/configuration.rb
  7. 1
      packaging/conf/configuration.yml
  8. 51
      spec/lib/open_project/configuration_spec.rb

@ -60,6 +60,7 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="form--field"><%= setting_text_field :smtp_user_name, container_class: '-middle' %></div>
<div class="form--field"><%= setting_password :smtp_password, container_class: '-middle' %></div>
<div class="form--field"><%= setting_check_box :smtp_enable_starttls_auto %></div>
<div class="form--field"><%= setting_check_box :smtp_ssl %></div>
</div>
<div id="email_delivery_method_sendmail" class="email_delivery_method_settings">
<div class="form--field"><%= setting_text_field :sendmail_location %></div>

@ -91,6 +91,18 @@
# smtp_user_name: "your_email@gmail.com"
# smtp_password: "your_password"
#
# ==== SMTP server at using SSL
#
# production:
# email_delivery_method: "smtp"
# smtp_enable_starttls_auto: false
# smtp_ssl: true
# smtp_address: "smtp.gmail.com"
# smtp_port: 587
# smtp_domain: "smtp.gmail.com" # 'your.domain.com' for GoogleApps
# smtp_authentication: :plain
# smtp_user_name: "your_email@gmail.com"
# smtp_password: "your_password"
#
# === More configuration options
#

@ -713,7 +713,7 @@ zh:
- 周五
- 周六
abbr_month_names:
-
-
- 1月
- 2月
- 3月
@ -739,7 +739,7 @@ zh:
long: "%B %d, %Y"
short: "%b %d"
month_names:
-
-
- 1月
- 2月
- 3月
@ -1924,6 +1924,7 @@ zh:
setting_email_delivery_method: 电子邮件发送方法
setting_sendmail_location: Sendmail 的执行位置
setting_smtp_enable_starttls_auto: 如果可用,自动使用 STARTTLS
setting_smtp_ssl: "使用 SSL 连接"
setting_smtp_address: SMTP 服务器
setting_smtp_port: SMTP 端口
setting_smtp_authentication: SMTP 身份验证

@ -2000,6 +2000,7 @@ en:
setting_email_delivery_method: "Email delivery method"
setting_sendmail_location: "Location of the sendmail executable"
setting_smtp_enable_starttls_auto: "Automatically use STARTTLS if available"
setting_smtp_ssl: "Use SSL connection"
setting_smtp_address: "SMTP server"
setting_smtp_port: "SMTP port"
setting_smtp_authentication: "SMTP authentication"

@ -41,6 +41,9 @@ smtp_openssl_verify_mode:
smtp_enable_starttls_auto:
default: 0
format: boolean
smtp_ssl:
default: 0
format: boolean
smtp_address:
default: ""
smtp_port:

@ -352,6 +352,7 @@ module OpenProject
end
ActionMailer::Base.smtp_settings[:enable_starttls_auto] = Setting.smtp_enable_starttls_auto?
ActionMailer::Base.smtp_settings[:ssl] = Setting.smtp_ssl?
end
##

@ -37,6 +37,7 @@ default:
smtp_user_name: <%= ENV['SMTP_USERNAME'] %>
smtp_password: <%= ENV['SMTP_PASSWORD'] %>
smtp_enable_starttls_auto: <%= ENV.fetch('SMTP_ENABLE_STARTTLS_AUTO') { "false" } %>
smtp_ssl: <%= ENV.fetch('SMTP_SSL') { "false" } %>
attachments_storage_path: <%= ENV.fetch('ATTACHMENTS_STORAGE_PATH') { "/var/db/_APP_NAME_/files" } %>
<% git_configured = ENV['GIT_REPOSITORIES'].present? %>
<% svn_configured = ENV['SVN_REPOSITORIES'].present? %>

@ -273,6 +273,7 @@ describe OpenProject::Configuration do
OpenProject::Configuration['smtp_port'] = 587
OpenProject::Configuration['smtp_user_name'] = 'username'
OpenProject::Configuration['smtp_enable_starttls_auto'] = true
OpenProject::Configuration['smtp_ssl'] = true
expect(OpenProject::Configuration.migrate_mailer_configuration!).to eq(true)
expect(Setting.email_delivery_method).to eq(:smtp)
@ -281,6 +282,7 @@ describe OpenProject::Configuration do
expect(Setting.smtp_port).to eq(587)
expect(Setting.smtp_user_name).to eq('username')
expect(Setting.smtp_enable_starttls_auto?).to eq(true)
expect(Setting.smtp_ssl?).to eq(true)
end
end
@ -313,6 +315,7 @@ describe OpenProject::Configuration do
Setting.smtp_port = 25
Setting.smtp_user_name = 'username'
Setting.smtp_enable_starttls_auto = 1
Setting.smtp_ssl = 0
expect(action_mailer).to receive(:perform_deliveries=).with(true)
expect(action_mailer).to receive(:delivery_method=).with(:smtp)
@ -321,7 +324,28 @@ describe OpenProject::Configuration do
expect(action_mailer.smtp_settings).to eq(address: 'smtp.example.com',
port: 25,
domain: 'example.com',
enable_starttls_auto: true)
enable_starttls_auto: true,
ssl: false)
Setting.email_delivery_method = :smtp
Setting.smtp_authentication = :none
Setting.smtp_password = 'old'
Setting.smtp_address = 'smtp.example.com'
Setting.smtp_domain = 'example.com'
Setting.smtp_port = 25
Setting.smtp_user_name = 'username'
Setting.smtp_enable_starttls_auto = 0
Setting.smtp_ssl = 1
expect(action_mailer).to receive(:perform_deliveries=).with(true)
expect(action_mailer).to receive(:delivery_method=).with(:smtp)
OpenProject::Configuration.reload_mailer_configuration!
expect(action_mailer.smtp_settings[:smtp_authentication]).to be_nil
expect(action_mailer.smtp_settings).to eq(address: 'smtp.example.com',
port: 25,
domain: 'example.com',
enable_starttls_auto: false,
ssl: true)
end
it 'correctly sets the action mailer configuration based on the settings' do
@ -332,6 +356,28 @@ describe OpenProject::Configuration do
Setting.smtp_port = 587
Setting.smtp_user_name = 'username'
Setting.smtp_enable_starttls_auto = 1
Setting.smtp_ssl = 0
expect(action_mailer).to receive(:perform_deliveries=).with(true)
expect(action_mailer).to receive(:delivery_method=).with(:smtp)
OpenProject::Configuration.reload_mailer_configuration!
expect(action_mailer.smtp_settings).to eq(address: 'smtp.example.com',
port: 587,
domain: 'example.com',
authentication: 'plain',
user_name: 'username',
password: 'p4ssw0rd',
enable_starttls_auto: true,
ssl: false)
Setting.email_delivery_method = :smtp
Setting.smtp_password = 'p4ssw0rd'
Setting.smtp_address = 'smtp.example.com'
Setting.smtp_domain = 'example.com'
Setting.smtp_port = 587
Setting.smtp_user_name = 'username'
Setting.smtp_enable_starttls_auto = 0
Setting.smtp_ssl = 1
expect(action_mailer).to receive(:perform_deliveries=).with(true)
expect(action_mailer).to receive(:delivery_method=).with(:smtp)
@ -342,7 +388,8 @@ describe OpenProject::Configuration do
authentication: 'plain',
user_name: 'username',
password: 'p4ssw0rd',
enable_starttls_auto: true)
enable_starttls_auto: false,
ssl: true)
end
end

Loading…
Cancel
Save