fix email not deliver error

This commit is contained in:
chiu 2020-03-22 21:47:21 +08:00
parent 9c2853eae8
commit 23abca1d4d
2 changed files with 3 additions and 0 deletions

View File

@ -336,6 +336,7 @@ class Admin::AnnouncementsController < OrbitAdminController
if bulletin.email.nil? if bulletin.email.nil?
email = Email.new email = Email.new
email.save email.save
email.deliver rescue nil
bulletin.email_id = email.id bulletin.email_id = email.id
bulletin.save bulletin.save
end end

View File

@ -127,6 +127,7 @@ module Admin::AnnouncementsHelper
url = "http://#{request.host_with_port}/admin/announcements/#{announcement.id}/edit" url = "http://#{request.host_with_port}/admin/announcements/#{announcement.id}/edit"
datatosend = "<h3>Hello #{user.name},</h3><p>#{current_user.name} #{t("announcement.rejected_annoucement")} : #{announcement.rejection_reason} <a href='#{url}'> #{t("announcement.click_here_to_see")}</a></p>" datatosend = "<h3>Hello #{user.name},</h3><p>#{current_user.name} #{t("announcement.rejected_annoucement")} : #{announcement.rejection_reason} <a href='#{url}'> #{t("announcement.click_here_to_see")}</a></p>"
mail = Email.new(:mail_to => email, :mail_subject => "Announcement rejected公告未通過 : #{announcement.title}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend}) 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 mail.deliver rescue nil
end end
end end
@ -170,6 +171,7 @@ module Admin::AnnouncementsHelper
datatosend = "<h3>#{t("announcement.approval_mail_hi", :name => name)},</h3><p>#{t("announcement.updated_annoucement", :poster => current_user.name)}<br /><br />#{t("announcement.approval_announcement_title")} : #{announcement.title} <br /> #{t("announcement.click_here_to_see")} : <a href='#{url}'> #{url} </a></p>" datatosend = "<h3>#{t("announcement.approval_mail_hi", :name => name)},</h3><p>#{t("announcement.updated_annoucement", :poster => current_user.name)}<br /><br />#{t("announcement.approval_announcement_title")} : #{announcement.title} <br /> #{t("announcement.click_here_to_see")} : <a href='#{url}'> #{url} </a></p>"
end 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 = 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 email.deliver rescue nil
end end