From 78a3625619afdc9781a7a63de11d8560dfa6cb50 Mon Sep 17 00:00:00 2001 From: Ryan Rusnak Date: Wed, 24 Sep 2014 17:49:21 -0400 Subject: [PATCH 01/10] adding template --- app/mailers/contact_mailer.rb | 4 +- app/views/contact_mailer/contact_us.html.erb | 88 +++++++++++++++++--- 2 files changed, 80 insertions(+), 12 deletions(-) diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index c316c88..ff3e5ff 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -2,8 +2,10 @@ class ContactMailer < ActionMailer::Base def contact_us(from, return_email, message) @from = from @message = message + @return_email = return_email + attachments.inline['logo.png'] = File.read('app/assets/images/myusa-logo.png') mail( - reply_to: return_email, + reply_to: @return_email, subject: t('email.contact_us.subject') ) end diff --git a/app/views/contact_mailer/contact_us.html.erb b/app/views/contact_mailer/contact_us.html.erb index b4e3991..a40426c 100644 --- a/app/views/contact_mailer/contact_us.html.erb +++ b/app/views/contact_mailer/contact_us.html.erb @@ -1,12 +1,78 @@ - - + + - - - -

New message from <%= @from %>

-

- <%= @message %> -

- - + + *|MC:SUBJECT|* + <%= stylesheet_link_tag "mailers" %> + + +
+ + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + +
+ <%= link_to image_tag(attachments['logo.png'].url, alt: 'Our Photo', height: '50', width: '100', alt: 'Sent from MyUSA'), root_url -%> +
+ +
+ + + + + + +
+

New message from <%= @from %>

+
+ +
+ + + + + +
+

Return email: <%= @return_email %>

+

<%= @message %>

+
+ +
+ + + + + +
+
+ +
+ +
+
+ + \ No newline at end of file From 01e14a03704a4bdd788f4046c3ed14dda7eb9330 Mon Sep 17 00:00:00 2001 From: Ryan Rusnak Date: Fri, 26 Sep 2014 12:08:11 -0400 Subject: [PATCH 02/10] updating mailer test --- spec/mailers/contact_mailer_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/mailers/contact_mailer_spec.rb b/spec/mailers/contact_mailer_spec.rb index 80a4bcc..9c2a0ab 100644 --- a/spec/mailers/contact_mailer_spec.rb +++ b/spec/mailers/contact_mailer_spec.rb @@ -11,7 +11,7 @@ its(:subject) { should eql 'Contact - MyUSA marketing page' } its(:reply_to) { should contain_exactly email } # its('body.encoded') { should include message } - its(:body) { should include message } - its(:body) { should include 'User Name'} + its('body.encoded') { should include message } + its('body.encoded') { should include 'User Name'} end end From aa5346c58b9da8879698ad4d7f3c29ec16a9045f Mon Sep 17 00:00:00 2001 From: Ryan Rusnak Date: Fri, 26 Sep 2014 14:51:40 -0400 Subject: [PATCH 03/10] creating shared mail template --- app/mailers/contact_mailer.rb | 1 + app/mailers/notification_mailer.rb | 1 + app/views/contact_mailer/contact_us.html.erb | 40 +------------------ .../mailers/notification_template.html.erb | 39 ++++++++++++++++++ .../notification_email.html.erb | 40 +------------------ 5 files changed, 43 insertions(+), 78 deletions(-) create mode 100644 app/views/layouts/mailers/notification_template.html.erb diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index ff3e5ff..090254e 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -1,4 +1,5 @@ class ContactMailer < ActionMailer::Base + layout 'mailers/notification_template' def contact_us(from, return_email, message) @from = from @message = message diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index caf1670..d2d1fba 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -1,4 +1,5 @@ class NotificationMailer < ActionMailer::Base + layout 'mailers/notification_template' def notification_email(notification) @notification = notification @app = @notification.app diff --git a/app/views/contact_mailer/contact_us.html.erb b/app/views/contact_mailer/contact_us.html.erb index a40426c..6df098e 100644 --- a/app/views/contact_mailer/contact_us.html.erb +++ b/app/views/contact_mailer/contact_us.html.erb @@ -1,33 +1,3 @@ - - - - - *|MC:SUBJECT|* - <%= stylesheet_link_tag "mailers" %> - - -
- - - - -
- - - - -
- - - - - - - - -
- <%= link_to image_tag(attachments['logo.png'].url, alt: 'Our Photo', height: '50', width: '100', alt: 'Sent from MyUSA'), root_url -%> -
- -
@@ -67,12 +37,4 @@
- - - - -
- - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/layouts/mailers/notification_template.html.erb b/app/views/layouts/mailers/notification_template.html.erb new file mode 100644 index 0000000..a6541db --- /dev/null +++ b/app/views/layouts/mailers/notification_template.html.erb @@ -0,0 +1,39 @@ + + + + + *|MC:SUBJECT|* + <%= stylesheet_link_tag "mailers" %> + + +
+ + + + +
+ + + + + + <%= yield %> +
+ + + + + + + + +
+ <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '50', width: '100', alt: 'Sent from MyUSA'), root_url -%> +
+ +
+ +
+
+ + \ No newline at end of file diff --git a/app/views/notification_mailer/notification_email.html.erb b/app/views/notification_mailer/notification_email.html.erb index 1985833..833cafd 100644 --- a/app/views/notification_mailer/notification_email.html.erb +++ b/app/views/notification_mailer/notification_email.html.erb @@ -1,33 +1,3 @@ - - - - - *|MC:SUBJECT|* - <%= stylesheet_link_tag "mailers" %> - - -
- - - - -
- - - - -
- - - - - - - - -
- <%= link_to image_tag(attachments['logo.png'].url, height: '50', width: '100', alt: 'Sent from MyUSA'), root_url -%> -
- -
@@ -69,12 +39,4 @@
- - - - -
- - \ No newline at end of file + \ No newline at end of file From 7db99e4f6005fbef23dcb8fe57ebff4223ee05d8 Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Tue, 7 Oct 2014 22:21:40 +0000 Subject: [PATCH 04/10] Update formating (2 spaces), remove comment, fix image sizes --- app/views/contact_mailer/contact_us.html.erb | 80 +++++++++---------- .../authentication_instructions.html.erb | 2 +- .../mailers/notification_template.html.erb | 68 ++++++++-------- spec/mailers/contact_mailer_spec.rb | 1 - 4 files changed, 75 insertions(+), 76 deletions(-) diff --git a/app/views/contact_mailer/contact_us.html.erb b/app/views/contact_mailer/contact_us.html.erb index 6df098e..6ef5529 100644 --- a/app/views/contact_mailer/contact_us.html.erb +++ b/app/views/contact_mailer/contact_us.html.erb @@ -1,40 +1,40 @@ - - - - - - - - -
-

New message from <%= @from %>

-
- - - - - - - - - - -
-

Return email: <%= @return_email %>

-

<%= @message %>

-
- - - - - - - - - - -
-
- - - \ No newline at end of file + + + + + + + + +
+

New message from <%= @from %>

+
+ + + + + + + + + + +
+

Return email: <%= @return_email %>

+

<%= @message %>

+
+ + + + + + + + + + +
+
+ + + diff --git a/app/views/devise_mailer/authentication_instructions.html.erb b/app/views/devise_mailer/authentication_instructions.html.erb index a01243b..9dcfc29 100644 --- a/app/views/devise_mailer/authentication_instructions.html.erb +++ b/app/views/devise_mailer/authentication_instructions.html.erb @@ -36,7 +36,7 @@
- <%= image_tag attachments['logo.png'].url, alt: 'Sent by MyUSA', class: 'photo', height: '150', width: '200', class: 'left-20' -%> + <%= image_tag attachments['logo.png'].url, alt: 'Sent by MyUSA', class: 'photo', height: '38', width: '134', class: 'left-20' -%>
diff --git a/app/views/layouts/mailers/notification_template.html.erb b/app/views/layouts/mailers/notification_template.html.erb index a6541db..159bd3b 100644 --- a/app/views/layouts/mailers/notification_template.html.erb +++ b/app/views/layouts/mailers/notification_template.html.erb @@ -1,39 +1,39 @@ - - *|MC:SUBJECT|* - <%= stylesheet_link_tag "mailers" %> - - -
- + + *|MC:SUBJECT|* + <%= stylesheet_link_tag "mailers" %> + + +
+
+ + + +
+ + - - + + + <%= yield %>
- - - - - - <%= yield %> -
- - - - - - - - -
- <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '50', width: '100', alt: 'Sent from MyUSA'), root_url -%> -
- -
- -
+ + + + + + + + +
+ <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '38', width: '134', alt: 'Sent from MyUSA'), root_url -%> +
+ +
- - - \ No newline at end of file + +
+
+ + diff --git a/spec/mailers/contact_mailer_spec.rb b/spec/mailers/contact_mailer_spec.rb index 9c2a0ab..f3958d2 100644 --- a/spec/mailers/contact_mailer_spec.rb +++ b/spec/mailers/contact_mailer_spec.rb @@ -10,7 +10,6 @@ its(:subject) { should eql 'Contact - MyUSA marketing page' } its(:reply_to) { should contain_exactly email } - # its('body.encoded') { should include message } its('body.encoded') { should include message } its('body.encoded') { should include 'User Name'} end From 17f7283407f2f04985973bb9d67600e47300d0b7 Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Tue, 7 Oct 2014 22:45:09 +0000 Subject: [PATCH 05/10] Minor tweaks to improve email readability --- .../devise_mailer/authentication_instructions.html.erb | 6 ++++-- app/views/layouts/mailers/notification_template.html.erb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/devise_mailer/authentication_instructions.html.erb b/app/views/devise_mailer/authentication_instructions.html.erb index 9dcfc29..72289d8 100644 --- a/app/views/devise_mailer/authentication_instructions.html.erb +++ b/app/views/devise_mailer/authentication_instructions.html.erb @@ -36,7 +36,7 @@
- <%= image_tag attachments['logo.png'].url, alt: 'Sent by MyUSA', class: 'photo', height: '38', width: '134', class: 'left-20' -%> + <%= image_tag attachments['logo.png'].url, alt: 'Sent by MyUSA', class: 'photo', height: '38', width: '134', class: 'left-20' %>
@@ -51,8 +51,10 @@

Hello there <%= @resource.email %>

Below is your requested <%= link_to 'access link', new_user_session_url(email: @resource.email, token: @token.raw).html_safe %> to connect to MyUSA.

+

<%= link_to 'Connect to MyUSA', new_user_session_url(email: @resource.email, token: @token.raw).html_safe, :class => 'btn-myusa' %> -

If you do not want to connect to MyUSA from this email account, just ignore this message.

+

+

If you do not want to connect to MyUSA from this email account, just ignore this message.

Thanks!

- The MyUSA team

diff --git a/app/views/layouts/mailers/notification_template.html.erb b/app/views/layouts/mailers/notification_template.html.erb index 159bd3b..b74e2d8 100644 --- a/app/views/layouts/mailers/notification_template.html.erb +++ b/app/views/layouts/mailers/notification_template.html.erb @@ -18,7 +18,7 @@ From b484eb9b9a912d364eaac9045dde4066e3c00ac1 Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Tue, 7 Oct 2014 23:01:58 +0000 Subject: [PATCH 06/10] Let email defaults take over, reduce config overhead Fix two things: - the reply-to is already being set to myusa@gsa.gov by the action mailer defaults - emails for notifications should NOT come from no-reply@[app_domain] Instead they should come from the default myusa address no-reply@[myusa_host] This commit fixes these items. --- app/mailers/notification_mailer.rb | 2 -- app/models/notification.rb | 5 ----- spec/mailers/notification_mailer_spec.rb | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index d2d1fba..d1d0986 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -7,8 +7,6 @@ def notification_email(notification) attachments.inline['logo.png'] = File.read('app/assets/images/myusa-logo.png') mail( to: @user.email, - from: @notification.email_from_address, - reply_to: 'myusa@gsa.gov', subject: @notification.subject ) end diff --git a/app/models/notification.rb b/app/models/notification.rb index 098082c..0f75321 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -16,11 +16,6 @@ def view! self.update_attribute :viewed_at, Time.now end - def email_from_address - url = app.url.blank? ? app.redirect_uri : app.url - "no-reply@#{URI(url).host}" - end - private def deliver_notification diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index b2494ef..01ea5c5 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -17,7 +17,7 @@ end subject { NotificationMailer.notification_email(notification) } - its(:from) { should eql ['no-reply@example.com'] } + its(:from) { should eql ['no-reply@' + ActionMailer::Base.default_url_options[:host]] } its(:subject) { should eql notification.subject } its(:reply_to) { should contain_exactly 'myusa@gsa.gov' } its('body.encoded') { should have_content notification.body } From c715f3ee037f8a46669b5866053378dd0d8612db Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Wed, 8 Oct 2014 00:29:53 +0000 Subject: [PATCH 07/10] Add failure conditions for contact form If the form fails, show a failure message to the user. --- app/assets/javascripts/myusa.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/myusa.js b/app/assets/javascripts/myusa.js index 8193cc0..49a3db2 100644 --- a/app/assets/javascripts/myusa.js +++ b/app/assets/javascripts/myusa.js @@ -137,8 +137,13 @@ $(document).ready(function () { $('.contact-flash').removeClass('hidden'); btn.button('reset'); btn.prop('disabled', false); + form[0].reset(); + }).fail(function (error) { + $('.contact-flash .message').text("Whoops! Something went wrong. We're really sorry. Try emailing us at myusa@gsa.gov."); + $('.contact-flash').removeClass('hidden'); + btn.button('reset'); + btn.prop('disabled', false); }); - form[0].reset(); }); }); From 47d0ee4b4afafbf9dc3cd864eb398216c17b6e44 Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Wed, 8 Oct 2014 00:30:16 +0000 Subject: [PATCH 08/10] Remove borders in emails, since we don't want them. --- app/assets/stylesheets/mailers.css.scss | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/assets/stylesheets/mailers.css.scss b/app/assets/stylesheets/mailers.css.scss index dc0341e..a4d004f 100644 --- a/app/assets/stylesheets/mailers.css.scss +++ b/app/assets/stylesheets/mailers.css.scss @@ -52,14 +52,11 @@ body, #bodyTable{ background-color:#ffffff; } #bodyCell{ - border-top:4px solid #BBBBBB; } #templateContainer{ - border:1px solid #BBBBBB; } #templatePreheader{ background-color:#F4F4F4; - border-bottom:1px solid #CCCCCC; } .preheaderContent{ color:#808080; @@ -75,8 +72,6 @@ body, #bodyTable{ } #templateHeader{ background-color:#F4F4F4; - border-top:1px solid #FFFFFF; - border-bottom:1px solid #CCCCCC; } .headerContent{ color:#505050; @@ -106,8 +101,6 @@ body, #bodyTable{ /* ========== Body Styles ========== */ #templateBody{ background-color:#F4F4F4; - border-top:1px solid #FFFFFF; - border-bottom:1px solid #CCCCCC; } .bodyContent a:link, .bodyContent a:visited, /* Yahoo! Mail Override */ .bodyContent a .yshortcuts /* Yahoo! Mail Override */{ color:$blue-dark; @@ -128,7 +121,7 @@ body, #bodyTable{ a.btn-myusa{ font: bold 15px Arial; text-decoration: none; - background-color: $blue-dark; + background-color: $blue; padding: 4px 12px 4px 12px; border-top: 1px solid #CCCCCC; @@ -149,7 +142,6 @@ body, #bodyTable{ /* ========== Footer Styles ========== */ #templateFooter{ background-color:#F4F4F4; - border-top:1px solid #FFFFFF; } .footerContent{ color:#808080; From ff358c16a080a4e63899f73807c393faf381e1ef Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Wed, 8 Oct 2014 00:30:52 +0000 Subject: [PATCH 09/10] Make contact form more usable - Subject updated to tell you who it is from - Image/logo update to be the right size --- app/mailers/contact_mailer.rb | 2 +- app/views/contact_mailer/contact_us.html.erb | 6 +++++- app/views/layouts/mailers/notification_template.html.erb | 2 +- app/views/marketing/_contact.html.erb | 2 +- config/locales/en.yml | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index 090254e..d86e30e 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -7,7 +7,7 @@ def contact_us(from, return_email, message) attachments.inline['logo.png'] = File.read('app/assets/images/myusa-logo.png') mail( reply_to: @return_email, - subject: t('email.contact_us.subject') + subject: I18n.t('email.contact_us.subject', from: @from) ) end end diff --git a/app/views/contact_mailer/contact_us.html.erb b/app/views/contact_mailer/contact_us.html.erb index 6ef5529..49bc863 100644 --- a/app/views/contact_mailer/contact_us.html.erb +++ b/app/views/contact_mailer/contact_us.html.erb @@ -18,7 +18,11 @@
- <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '38', width: '134', alt: 'Sent from MyUSA'), root_url -%> + <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '38', width: '134', alt: 'Sent from MyUSA'), root_url %>
diff --git a/app/views/layouts/mailers/notification_template.html.erb b/app/views/layouts/mailers/notification_template.html.erb index b74e2d8..29954d9 100644 --- a/app/views/layouts/mailers/notification_template.html.erb +++ b/app/views/layouts/mailers/notification_template.html.erb @@ -18,7 +18,7 @@
-

Return email: <%= @return_email %>

+

+ From: <%= @from %> +
+ Email: <%= @return_email %> +

<%= @message %>

diff --git a/app/views/marketing/_contact.html.erb b/app/views/marketing/_contact.html.erb index 00691f6..08cdf4a 100644 --- a/app/views/marketing/_contact.html.erb +++ b/app/views/marketing/_contact.html.erb @@ -23,7 +23,7 @@ <%= f.label 'Return Email:' %> <%= f.text_field :return_email, class: 'form-control', placeholder: 'What is your email address?' %> - <%= f.submit 'Send Us Your Message', id: 'contact_submit', 'data-loading-text' => "Sending your message...", class: 'btn btn-primary width-100' %> + <%= f.submit 'Send Us Your Message', id: 'contact_submit', 'data-loading-text' => "Sending your message...", class: 'btn btn-primary width-100' %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index f9b7955..7e7b475 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -213,7 +213,7 @@ en: email: contact_us: - subject: 'Contact - MyUSA marketing page' + subject: MyUSA question from %{from} mobile_confirmation: bad_token: 'Please check the number sent to your mobile and re-enter that code. If that seems to match, you can also resend a code or re-enter your mobile number.' From 20849dc42f32da6596b1140225bd44ec19591e8a Mon Sep 17 00:00:00 2001 From: Joe Polastre Date: Wed, 8 Oct 2014 00:35:34 +0000 Subject: [PATCH 10/10] Update spec for new contact email subject --- spec/mailers/contact_mailer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mailers/contact_mailer_spec.rb b/spec/mailers/contact_mailer_spec.rb index f3958d2..e1ddb3a 100644 --- a/spec/mailers/contact_mailer_spec.rb +++ b/spec/mailers/contact_mailer_spec.rb @@ -8,7 +8,7 @@ subject { ContactMailer.contact_us('User Name', email, message) } - its(:subject) { should eql 'Contact - MyUSA marketing page' } + its(:subject) { should eql 'MyUSA question from User Name' } its(:reply_to) { should contain_exactly email } its('body.encoded') { should include message } its('body.encoded') { should include 'User Name'}
- <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '38', width: '134', alt: 'Sent from MyUSA'), root_url %> + <%= link_to image_tag(attachments['logo.png'].url, alt: 'Sent from MyUSA', height: '25', width: '88', alt: 'Sent from MyUSA'), root_url %>