[Fix #196] Attestation: join the attestation to the closed mail

Add a upper limit to the attachment size as it could be a problem with Mailjet and receiver
(https://www.mailjet.com/support/what-is-the-size-limit-for-attachments-files-sent-via-mailjet,289.htm)

If the attestation cannot be sent, it is logged in sentry
This commit is contained in:
Simon Lehericey 2017-06-09 22:29:48 +02:00
parent b664709c3d
commit e60ce35ae8
7 changed files with 114 additions and 18 deletions

View file

@ -3,12 +3,16 @@ class NotificationMailer < ApplicationMailer
after_action :create_commentaire_for_notification, only: :send_notification
def send_notification(dossier, mail_template)
def send_notification(dossier, mail_template, attestation = nil)
vars_mailer(dossier)
@object = mail_template.object_for_dossier dossier
@body = mail_template.body_for_dossier dossier
if attestation.present?
attachments['attestation.pdf'] = attestation
end
mail(subject: @object) { |format| format.html { @body } }
end