From 23abca1d4d35d2d5d0a0fcbf761acdd9faed225d Mon Sep 17 00:00:00 2001 From: chiu Date: Sun, 22 Mar 2020 21:47:21 +0800 Subject: [PATCH] fix email not deliver error --- app/controllers/admin/announcements_controller.rb | 1 + app/helpers/admin/announcements_helper.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index cdabadb..89b1f06 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -336,6 +336,7 @@ class Admin::AnnouncementsController < OrbitAdminController if bulletin.email.nil? email = Email.new email.save + email.deliver rescue nil bulletin.email_id = email.id bulletin.save end diff --git a/app/helpers/admin/announcements_helper.rb b/app/helpers/admin/announcements_helper.rb index a174cb9..847dd10 100644 --- a/app/helpers/admin/announcements_helper.rb +++ b/app/helpers/admin/announcements_helper.rb @@ -127,6 +127,7 @@ module Admin::AnnouncementsHelper url = "http://#{request.host_with_port}/admin/announcements/#{announcement.id}/edit" datatosend = "

Hello #{user.name},

#{current_user.name} #{t("announcement.rejected_annoucement")} : #{announcement.rejection_reason} #{t("announcement.click_here_to_see")}

" mail = Email.new(:mail_to => email, :mail_subject => "Announcement rejected公告未通過 : #{announcement.title}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend}) + mail.save mail.deliver rescue nil end end @@ -170,6 +171,7 @@ module Admin::AnnouncementsHelper datatosend = "

#{t("announcement.approval_mail_hi", :name => name)},

#{t("announcement.updated_annoucement", :poster => current_user.name)}

#{t("announcement.approval_announcement_title")} : #{announcement.title}
#{t("announcement.click_here_to_see")} : #{url}

" end email = Email.new(:mail_to => useremail, :mail_subject => " #{t("announcement.announcement_subject")} : #{announcement.title}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend}) + email.save email.deliver rescue nil end