support-foo/web

View on GitHub
app/views/accounts/_email_forwarding.html.erb

Summary

Maintainability
Test Coverage
<%= form_for(@account, method: :patch, html: {class: 'form mb4'}) do |f| %>
  <%= f.label :forwarding_address, 'Custom sending address', class: 'control-label' %>
  <p class="help-block h6 mt1 mb2">Send emails from an address listed on your own domain. In order for Helpful to send emails on behalf of this address, you need to setup the proper SPF records on your domain. If you don't setup the SPF records correctly, there is a chance your support emails could be marked as spam.</p>
  <div class="clearfix mxn3">
    <div class="col col-8 px3">
      <%= f.text_field :forwarding_address, class: 'form-control' %>
    </div>
    <div class="col col-4 px3">
      <%= f.button (f.object.forwarding_address? ? 'Update address' : 'Add custom address'), class: 'btn btn-default' %>
    </div>
  </div>
<% end %>

<% if @account.forwarding_address? %>
  <table class="table">
    <thead>
      <tr>
        <th>Domain</th>
        <th>SPF configured</th>
        <th>Last checked</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><%= @account.forwarding_domain %></td>
        <% if @account.latest_domain_check.present? %>
          <td>
            <% if @account.latest_domain_check.spf_valid? %>
              <span class="fa fa-check"></span>
            <% else %>
              <span class="fa fa-times"></span>
            <% end %>
          </td>
          <td>
            <%= time_ago_in_words(@account.latest_domain_check.created_at) %> ago
          </td>
        <% else %>
          <td colspan="2">Checking domain configuration…</td>
        <% end %>
      </tr>
    </tbody>
  </table>
<% end %>

<hr class="mt4 mb4">

<h4>Setting up email forwarding on your domain</h4>

<p>You can send support emails from your own domain by setting up SPF records on your domain. Go into your DNS provider and add this TXT record to your root domain:</p>
<pre>
  <code>
    v=spf1 a include:helpful.io ~all
  </code>
</pre>
<p>If you already have a similar TXT record (for instance if you're using Google Apps), just add <code>include:helpful.io</code> to the record like this:</p>
<pre>
  <code>
    v=spf1 a include:_spf.google.com include:helpful.io ~all
  </code>
</pre>