demarches-normaliennes/app/mailers/application_mailer.rb

27 lines
956 B
Ruby
Raw Normal View History

2015-12-14 16:09:20 +01:00
class ApplicationMailer < ActionMailer::Base
helper :application # gives access to all helpers defined within `application_helper`.
2018-05-31 15:45:25 +02:00
default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>"
2015-12-14 16:09:20 +01:00
layout 'mailer'
# Dont retry to send a message if the server rejects the recipient address
rescue_from Net::SMTPSyntaxError do |_error|
message.perform_deliveries = false
end
# Attach the procedure logo to the email (if any).
# Returns the attachment url.
def attach_logo(procedure)
2019-08-28 13:11:58 +02:00
if procedure.logo.attached?
logo_filename = procedure.logo.filename.to_s
attachments.inline[logo_filename] = procedure.logo.download
2019-08-28 14:27:41 +02:00
attachments[logo_filename].url
end
2019-08-28 13:11:58 +02:00
rescue StandardError => e
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
Raven.extra_context(procedure_id: procedure.id)
Raven.capture_exception(e)
nil
end
2015-12-14 16:09:20 +01:00
end