docbrown/app/views/admin/settings/forms/_smtp.html.erb
Ridhwana b21397a8c6
"Reply to" and "From" Email addresses for SMTP Configurations (#16499)
* feat: create a from_email_address and a reply_to_email_address

* feat: update other mailers with the new SMTP email settings

* test: update all spec files

* fix: use the SMTP::Settings value

* fix tests

* spec: fix the comma

* feat: tighten some logic

* fix: test

* fix tests

* fix tests

* final fix test commit

* fix test

* fix test

* oops

* feat: add a reply_to for Devise Mailer

* chore: update the description

* use a proc for reply_to

* feat: update text

* Update spec/mailers/digest_mailer_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/mailers/verification_mailer_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/mailers/shared_examples/renders_proper_email_headers.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* refactor: move OPTIONS to a helper as its only being used in the view layer

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-02-16 16:14:54 +02:00

49 lines
2.4 KiB
Text

<%= javascript_packs_with_chunks_tag "admin/config/smtp", defer: true %>
<%= form_for(Settings::SMTP.new,
url: admin_settings_smtp_settings_path,
html: { data: {
action: "submit->config#updateConfigurationSettings",
testid: "emailServerSettings"
} }) do |f| %>
<div class="card mt-3" id="smtp-section">
<%= render partial: "admin/shared/card_header",
locals: { header: "Email Server Settings (SMTP)", state: "collapse", target: "smtpSettingsBodyContainer", expanded: false } %>
<div id="smtpSettingsBodyContainer" class="card-body collapse hide" aria-labelledby="smtpSettingsBodyContainer">
<fieldset class="grid gap-4">
<% if ForemInstance.sendgrid_enabled? %>
<div class="crayons-field crayons-field--checkbox mt-3">
<%= f.check_box :own_email_server,
checked: Settings::SMTP.provided_minimum_settings?,
class: "crayons-checkbox" %>
<%= f.label :own_email_server, class: "crayons-field__label" do %>
Use my own email server
<% end %>
</div>
<% end %>
<% if ForemInstance.only_sendgrid_enabled? %>
<p class="mb-3">
As a Forem Cloud client, we provide an email server managed by the Forem team. All settings are managed by us and the from and reply email addresses are set as <%= ForemInstance.email %>. However, you can override this to use your own email server.
</p>
<% end %>
<div class="js-custom-smtp-section <%= "hidden" if ForemInstance.only_sendgrid_enabled? %>">
<% smpt_options.each do |config_key| %>
<div class="crayons-field mt-3">
<%= admin_config_label config_key, model: Settings::SMTP %>
<%= admin_config_description Constants::Settings::SMTP::DETAILS[config_key][:description] %>
<%= f.text_field config_key,
class: "crayons-textfield",
value: Settings::SMTP.public_send(config_key),
placeholder: Constants::Settings::SMTP::DETAILS[config_key][:placeholder],
"data-config-target": "smtpSetting#{config_key.to_s.camelize(:upper)}" %>
</div>
<% end %>
</div>
</fieldset>
<%= render "update_setting_button", f: f %>
</div>
</div>
<% end %>