diff --git a/Gemfile.lock b/Gemfile.lock index 5d04ded..956054a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -233,18 +233,18 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.3) + nokogiri (1.18.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.3-aarch64-linux-gnu) + nokogiri (1.18.4-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.3-arm-linux-gnu) + nokogiri (1.18.4-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.3-arm64-darwin) + nokogiri (1.18.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.3-x86_64-darwin) + nokogiri (1.18.4-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.3-x86_64-linux-gnu) + nokogiri (1.18.4-x86_64-linux-gnu) racc (~> 1.4) orm_adapter (0.5.0) pg (1.5.9) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index f6d3dd5..d8bd387 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,3 @@ class ApplicationMailer < ActionMailer::Base - default from: 'bearriver-questions@umich.edu' layout 'mailer' end diff --git a/app/mailers/test_mailer.rb b/app/mailers/test_mailer.rb new file mode 100644 index 0000000..de53325 --- /dev/null +++ b/app/mailers/test_mailer.rb @@ -0,0 +1,12 @@ +class TestMailer < ApplicationMailer + def test_email(recipient_email = nil) + @message = 'This is a test email from LSA Evaluate to verify email configuration.' + @sender = Rails.application.config.mailer_sender + @reply_to = 'lsa-wads-rails-email-test@umich.edu' + + mail( + to: recipient_email || 'lsa-wads-rails-email-test@umich.edu', + subject: 'Test Email from LSA Evaluate' + ) + end +end diff --git a/app/views/app_confirmation_mailer/application_submitted.html.erb b/app/views/app_confirmation_mailer/application_submitted.html.erb index 1353d9b..dab77cc 100644 --- a/app/views/app_confirmation_mailer/application_submitted.html.erb +++ b/app/views/app_confirmation_mailer/application_submitted.html.erb @@ -1,16 +1,3 @@ - - - - - - - -

- <%= @current_application_settings.application_confirm_email_message %> -

-

- <%= link_to "Bear River Conference site", "https://lsa.umich.edu/bearriver" %> -

-

Thank you,

- - +

+ <%= @current_application_settings.application_confirm_email_message %> +

diff --git a/app/views/app_confirmation_mailer/application_submitted.text.erb b/app/views/app_confirmation_mailer/application_submitted.text.erb index 0a76aee..2b080cd 100644 --- a/app/views/app_confirmation_mailer/application_submitted.text.erb +++ b/app/views/app_confirmation_mailer/application_submitted.text.erb @@ -1,7 +1 @@ -

- <%= @current_application_settings.application_confirm_email_message %> -

-

- <%= link_to "Bear River Conference site", "https://lsa.umich.edu/bearriver" %> -

-

Thank you,

\ No newline at end of file +<%= @current_application_settings.application_confirm_email_message %> diff --git a/app/views/balance_due_mailer/outstanding_balance.html.erb b/app/views/balance_due_mailer/outstanding_balance.html.erb index d9ebfa5..494e687 100644 --- a/app/views/balance_due_mailer/outstanding_balance.html.erb +++ b/app/views/balance_due_mailer/outstanding_balance.html.erb @@ -1,15 +1,6 @@ - - - - - - -

- <%= @current_application_settings.balance_due_email_message %> -

-

- <%= link_to "Bear River site", payments_url %> -

-

Thank you,

- - +

+ <%= @current_application_settings.balance_due_email_message %> +

+

+ <%= link_to "Bear River payments", payments_url %> +

diff --git a/app/views/balance_due_mailer/outstanding_balance.text.erb b/app/views/balance_due_mailer/outstanding_balance.text.erb index c40ffc3..d92ba7e 100644 --- a/app/views/balance_due_mailer/outstanding_balance.text.erb +++ b/app/views/balance_due_mailer/outstanding_balance.text.erb @@ -1,5 +1,3 @@ <%= @current_application_settings.balance_due_email_message %> -<%= link_to "Bear River site", payments_url %> - -Thank you, +Bear River payments https://bearriver.lsa.umich.edu diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index 8260180..647aab9 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -1,19 +1,63 @@ - - - - - + + + + + +
+
+ + +

Bear River Writers' Conference

+
+ <%= yield %> +
-

Bear River Writers' Conference

+

<%= link_to "Bear River Writers' Conference", "https://lsa.umich.edu/bearriver" %>

3187 Angell Hall
435 South State Street
Ann Arbor, MI 48109-1003

- - \ No newline at end of file +

+ If you have any questions, please contact <%= mail_to "bearriver-questions@umich.edu", "bearriver-questions@umich.edu" %> +

+ +
+ + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb index 08e9303..8847ad7 100644 --- a/app/views/layouts/mailer.text.erb +++ b/app/views/layouts/mailer.text.erb @@ -1,5 +1,15 @@ -<%= yield %> Bear River Writers' Conference +============================= + +<%= yield %> + +Bear River Writers' Conference - https://lsa.umich.edu/bearriver 3187 Angell Hall 435 South State Street -Ann Arbor, MI 48109-1003 \ No newline at end of file +Ann Arbor, MI 48109-1003 + +If you have any questions, please contact bearriver-questions@umich.edu + +--- +This is an automated email. Please do not reply to this message. +© <%= Date.today.year %> The Regents of the University of Michigan | All Rights Reserved diff --git a/app/views/lottery_mailer/lost_lottery_email.html.erb b/app/views/lottery_mailer/lost_lottery_email.html.erb index 44896e9..ffd1e88 100644 --- a/app/views/lottery_mailer/lost_lottery_email.html.erb +++ b/app/views/lottery_mailer/lost_lottery_email.html.erb @@ -1,15 +1,7 @@ - - - - - - -

- Hello <%= @application.first_name %> <%= @application.last_name %>, -

-

- <%= @lottery_lost_mail_body %> -

-

We thank you for your interest in Bear River.

- - +

+ Hello <%= @application.first_name %> <%= @application.last_name %>, +

+

+ <%= @lottery_lost_mail_body %> +

+

We thank you for your interest in Bear River.

diff --git a/app/views/lottery_mailer/pre_lottery_offer_email.html.erb b/app/views/lottery_mailer/pre_lottery_offer_email.html.erb index f247bd1..0ab53f3 100644 --- a/app/views/lottery_mailer/pre_lottery_offer_email.html.erb +++ b/app/views/lottery_mailer/pre_lottery_offer_email.html.erb @@ -1,18 +1,10 @@ - - - - - - -

- Congratulations <%= @application.first_name %> <%= @application.last_name %>! -

-

- <%= @special_offer_invite_email_body %> -

-

- <%= link_to "Accept Offer", accept_offer_url %> -

-

We look forward to you joining us at Bear River!

- - +

+ Congratulations <%= @application.first_name %> <%= @application.last_name %>! +

+

+ <%= @special_offer_invite_email_body %> +

+

+ <%= link_to "Accept Offer", accept_offer_url %> +

+

We look forward to you joining us at Bear River!

diff --git a/app/views/lottery_mailer/pre_lottery_offer_email.text.erb b/app/views/lottery_mailer/pre_lottery_offer_email.text.erb index cc7fbf6..0bbebee 100644 --- a/app/views/lottery_mailer/pre_lottery_offer_email.text.erb +++ b/app/views/lottery_mailer/pre_lottery_offer_email.text.erb @@ -2,6 +2,6 @@ Congratulations <%= @application.first_name %> <%= @application.last_name %>! <%= @special_offer_invite_email_body %> -<%= link_to "Accept Offer", accept_offer_url %> +Accept Offer -> https://bearriver.lsa.umich.edu/accept_offer We look forward to you joining us at Bear River! diff --git a/app/views/lottery_mailer/waitlisted_offer_email.html.erb b/app/views/lottery_mailer/waitlisted_offer_email.html.erb index f247bd1..0ab53f3 100644 --- a/app/views/lottery_mailer/waitlisted_offer_email.html.erb +++ b/app/views/lottery_mailer/waitlisted_offer_email.html.erb @@ -1,18 +1,10 @@ - - - - - - -

- Congratulations <%= @application.first_name %> <%= @application.last_name %>! -

-

- <%= @special_offer_invite_email_body %> -

-

- <%= link_to "Accept Offer", accept_offer_url %> -

-

We look forward to you joining us at Bear River!

- - +

+ Congratulations <%= @application.first_name %> <%= @application.last_name %>! +

+

+ <%= @special_offer_invite_email_body %> +

+

+ <%= link_to "Accept Offer", accept_offer_url %> +

+

We look forward to you joining us at Bear River!

diff --git a/app/views/lottery_mailer/waitlisted_offer_email.text.erb b/app/views/lottery_mailer/waitlisted_offer_email.text.erb index cc7fbf6..0bbebee 100644 --- a/app/views/lottery_mailer/waitlisted_offer_email.text.erb +++ b/app/views/lottery_mailer/waitlisted_offer_email.text.erb @@ -2,6 +2,6 @@ Congratulations <%= @application.first_name %> <%= @application.last_name %>! <%= @special_offer_invite_email_body %> -<%= link_to "Accept Offer", accept_offer_url %> +Accept Offer -> https://bearriver.lsa.umich.edu/accept_offer We look forward to you joining us at Bear River! diff --git a/app/views/lottery_mailer/won_lottery_email.html.erb b/app/views/lottery_mailer/won_lottery_email.html.erb index 256bb18..bf3890f 100644 --- a/app/views/lottery_mailer/won_lottery_email.html.erb +++ b/app/views/lottery_mailer/won_lottery_email.html.erb @@ -1,21 +1,10 @@ - - - - - - -

- Congratulations <%= @application.first_name %> <%= @application.last_name %>! -

-

- <%= @lottery_won_mail_body %> -

-

- <%= link_to "Accept Offer", accept_offer_url %> -

-

- We look forward to you joining us at Bear River! -

- - - +

+ Congratulations <%= @application.first_name %> <%= @application.last_name %>! +

+

+ <%= @lottery_won_mail_body %> +

+

+ <%= link_to "Accept Offer", accept_offer_url %> +

+

We look forward to you joining us at Bear River!

diff --git a/app/views/lottery_mailer/won_lottery_email.text.erb b/app/views/lottery_mailer/won_lottery_email.text.erb index c5c6de6..f0a9103 100644 --- a/app/views/lottery_mailer/won_lottery_email.text.erb +++ b/app/views/lottery_mailer/won_lottery_email.text.erb @@ -1,16 +1,7 @@ - - - - - - -

- Congratulations #{@application.first_name} #{@application.last_name}! -

- <%= @lottery_won_mail_body %> - <%= link_to "Accept Offer", accept_offer_url %> -

- We look forward to you joining us at Bear River! -

- - +Congratulations #{@application.first_name} #{@application.last_name}! + +<%= @lottery_won_mail_body %> + +Accept Offer -> https://bearriver.lsa.umich.edu/accept_offer + +We look forward to you joining us at Bear River! diff --git a/app/views/test_mailer/test_email.html.erb b/app/views/test_mailer/test_email.html.erb new file mode 100644 index 0000000..f5ab9fd --- /dev/null +++ b/app/views/test_mailer/test_email.html.erb @@ -0,0 +1,14 @@ +

Email Configuration Test

+ +

<%= @message %>

+ +

This message confirms your email settings are working correctly.

+ +

Email Configuration:

+ + +

This is a system-generated email. Please do not reply directly to this message.

+

If you need assistance, please contact <%= @reply_to %>.

diff --git a/app/views/test_mailer/test_email.text.erb b/app/views/test_mailer/test_email.text.erb new file mode 100644 index 0000000..2dc18b4 --- /dev/null +++ b/app/views/test_mailer/test_email.text.erb @@ -0,0 +1,13 @@ +Email Configuration Test +====================== + +<%= @message %> + +This message confirms your email settings are working correctly. + +Email Configuration: +- From: <%= @sender %> +- Reply-To: <%= @reply_to %> + +This is a system-generated email. Please do not reply directly to this message. +If you need assistance, please contact <%= @reply_to %>. diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index c99f9c1..b2c2a9c 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -dt7x+sHj4pT6dmwKsRVXdQFRm3Fyon724KTPW96OXnx6GDQ38i9cK9k24gDAi2+Kb37iyhrlyqTR8gghGIMJTs5kx87lVr1I/socltpl4byqi8CecDxKxSDFNXRh+B9U9XRejucIF6FPNc6KzI/5ybpgFPwy82mZEmWO+VH5eDuwe8JEqbtkmZKzLeALsD2EKuQyGbFb32MZnUVTOYmC6S93ThJSYbwevYH5H4FH6NLjmHzD8d1AjYWh/B9pvO7ys1hm1P05yF0A8QC6bDMLblH29ZAIs0eWhKN0a6Ae+bionPqSP98MhUWgRhb2VDAUXdGTtT60ALy6jbpxyVHCEzIn/1yY7SYcVOhSNTROIhKiEN008aonzexFgxFfYjuJoMCFb5JmD4+Kg8oRPoXB3hRnm9JNMDJpBToJvgWPxSZNKUWdv0zywS6TEdWBrDACb1ejow015MpjC5z8iomx/dm3eCXLF3X72QKwc7QQ2y1L6lHzlQj0v4TlmmBaY8kzLVOlR/PPlq3r/UK+P9Wj9Z9cLFXF3TiHaLgLtgtWfD9VeVqu8AHJ+bRZEWPmJA2cQULEcw4bH5sI5MoBvtsGJKMdGGH8+WzslGVZFBTzHSPqdv6gmdmWCoWBjBsbXFbVxqvclE8djrnJXSKMO6zzJDUlJv0hrWiUgjQ5xgcTdD74xF+2K5OJXQN1HdbGS0fafjainXpOdyzMIvzRGlt5iqiKeKb61iJUcCqEFM6d7mcp6xON1dKzH0b0xwCgRb6QamyAeem6iWi2JQB5V2SkjkXJt7V4HZa115Uv87HRq9hNiZRJ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Rwd90q3LaFPRfLNxfmHrtWHXvciROScKih2r6hHMbtNEAtaPbz3r7BICI+ALCgNflbiPfJZesDUvEE3RTbj+WzpWeTzJY7xT4lBsrSJT7uKz74Sp0rmSL4aHRI3rsj6YnZEIxPHzQ==--vF6peKEukVgJhOM9--mB45egvWtI47mU9i1SeB4A== \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index f938f87..e3281ed 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,6 +40,12 @@ # on staging use host = 'http://STAGING SERVER NAME' config.action_mailer.default_url_options = { host: host } + config.mailer_sender = Rails.application.credentials.dig(:devise, :mailer_sender) + config.action_mailer.default_options = { + from: config.mailer_sender, + reply_to: 'bearriver-questions@umich.edu' + } + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = true diff --git a/config/environments/production.rb b/config/environments/production.rb index 1712b71..22578b3 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -71,18 +71,23 @@ # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "bearriver2_production" - # The `perform_caching` option determines whether or not Action Mailer will - # cache emails. When set to `true`, Action Mailer will cache emails to improve - # performance. This can be useful if your application sends out a lot of emails - # that are identical or very similar, as it can reduce the amount of work the + # The `perform_caching` option determines whether or not Action Mailer will + # cache emails. When set to `true`, Action Mailer will cache emails to improve + # performance. This can be useful if your application sends out a lot of emails + # that are identical or very similar, as it can reduce the amount of work the # server has to do. - # When set to `false`, which means that Action Mailer will not cache emails. - # This might be because the emails your application sends are unique, so caching - # wouldn't provide a performance benefit. Or it might be to avoid potential issues + # When set to `false`, which means that Action Mailer will not cache emails. + # This might be because the emails your application sends are unique, so caching + # wouldn't provide a performance benefit. Or it might be to avoid potential issues # with stale or incorrect emails being sent out due to caching. config.action_mailer.perform_caching = false config.action_mailer.perform_deliveries = true - config.action_mailer.default_options = {from: 'bearriver-questions@umich.edu'} + # Set the default sender email (used by ActionMailer) + config.mailer_sender = Rails.application.credentials.dig(:devise, :mailer_sender) + config.action_mailer.default_options = { + from: config.mailer_sender, + reply_to: 'bearriver-questions@umich.edu' + } config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp host = 'https://bearriver.lsa.umich.edu/' diff --git a/config/environments/staging.rb b/config/environments/staging.rb index acc5866..65dabb7 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -74,7 +74,11 @@ host = 'https://bearriver-staging.lsa.umich.edu/' # on staging use host = 'http://STAGING SERVER NAME' config.action_mailer.default_url_options = { host: host } - + config.mailer_sender = Rails.application.credentials.dig(:devise, :mailer_sender) + config.action_mailer.default_options = { + from: config.mailer_sender, + reply_to: 'bearriver-questions@umich.edu' + } # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = true diff --git a/config/environments/test.rb b/config/environments/test.rb index adbb4a6..4da36e6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -38,6 +38,11 @@ config.active_storage.service = :test config.action_mailer.perform_caching = false + config.mailer_sender = Rails.application.credentials.dig(:devise, :mailer_sender) + config.action_mailer.default_options = { + from: config.mailer_sender, + reply_to: 'bearriver-questions@umich.edu' + } # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index a921108..ac92dcb 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -24,7 +24,7 @@ # 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 = 'bearriver-questions@umich.edu' + config.mailer_sender = Rails.application.credentials.dig(:devise, :mailer_sender) # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake new file mode 100644 index 0000000..e0e651f --- /dev/null +++ b/lib/tasks/email.rake @@ -0,0 +1,60 @@ +namespace :email do + # You can choose whether to queue the email through Sidekiq or send it directly: + # For direct delivery: + # bin/rails email:test[your@email.com] + # + # To queue through Sidekiq (add true as a second argument): + # bin/rails email:test[your@email.com,true] + + desc 'Send a test email to verify configuration' + task :test, [ :email, :queue ] => :environment do |_t, args| + recipient = args[:email] || Rails.application.credentials.dig(:devise, :mailer_sender) + + # Check if Sidekiq is available + sidekiq_available = defined?(Sidekiq) == 'constant' && Sidekiq.class == Module + queue_delivery_requested = args[:queue]&.downcase == 'true' + + # Set queue_delivery to false if Sidekiq is not available + queue_delivery = queue_delivery_requested && sidekiq_available + + # Show a warning if user requested Sidekiq but it's not available + if queue_delivery_requested && !sidekiq_available + puts "WARNING: Sidekiq is not available. Email will be sent directly." + end + + if recipient.nil? + puts 'ERROR: No recipient email provided and no default contact email configured.' + puts 'Usage: rake email:test[recipient@example.com] or rake email:test[recipient@example.com,true] to queue via Sidekiq' + exit 1 + end + + puts "Sending test email to #{recipient}..." + begin + if queue_delivery + # For queued delivery, don't inspect the message before sending + puts 'Queuing email delivery through Sidekiq...' + TestMailer.test_email(recipient).deliver_later + puts 'Email successfully queued in Sidekiq!' + else + # For direct delivery, we can inspect the message + mail = TestMailer.test_email(recipient) + + # Print message details before sending + puts 'Message details:' + puts " From: #{mail.from.first || 'Not set'}" + puts " Reply-To: #{mail.reply_to&.first || 'Not set'}" + puts " Subject: #{mail.subject || 'Not set'}" + puts 'Headers:' + mail.header.fields.each do |field| + puts " #{field.name}: #{field.value}" unless field.name =~ /content-/i + end + + mail.deliver_now + puts 'Test email sent directly (bypassing Sidekiq)!' + end + rescue => e + puts "ERROR: Failed to send test email: #{e.message}" + puts e.backtrace.join("\n") + end + end +end