Add no-reply email to transactional emails (#4265)

Emails : les emails transactionnels d'une démarche ont maintenant une adresse de réponse en NO_REPLY ; cette adresse renvoie un message d'orientation automatique en cas de réponse.
This commit is contained in:
Pierre de La Morinerie 2019-09-10 13:47:30 +02:00 committed by GitHub
commit a15bbd5b4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 6 deletions

View file

@ -7,4 +7,9 @@ class DeviseUserMailer < Devise::Mailer
def template_paths def template_paths
['devise_mailer'] ['devise_mailer']
end end
def confirmation_instructions(record, token, opts = {})
opts[:from] = NO_REPLY_EMAIL
super
end
end end

View file

@ -12,7 +12,7 @@ class DossierMailer < ApplicationMailer
subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »" subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »"
mail(to: dossier.user.email, subject: subject) do |format| mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' } format.html { render layout: 'mailers/notifications_layout' }
end end
end end
@ -24,7 +24,7 @@ class DossierMailer < ApplicationMailer
subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})" subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})"
mail(to: dossier.user.email, subject: subject) do |format| mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' } format.html { render layout: 'mailers/notifications_layout' }
end end
end end
@ -60,8 +60,13 @@ class DossierMailer < ApplicationMailer
def notify_revert_to_instruction(dossier) def notify_revert_to_instruction(dossier)
@dossier = dossier @dossier = dossier
@subject = "Votre dossier nº #{@dossier.id} est en train d'être réexaminé" @service = dossier.procedure.service
@logo_url = attach_logo(dossier.procedure)
mail(to: dossier.user.email, subject: @subject) subject = "Votre dossier nº #{@dossier.id} est en train d'être réexaminé"
mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' }
end
end end
end end

View file

@ -12,6 +12,7 @@ class NotificationMailer < ApplicationMailer
helper MailerHelper helper MailerHelper
layout 'mailers/notifications_layout' layout 'mailers/notifications_layout'
default from: NO_REPLY_EMAIL
def send_dossier_received(dossier) def send_dossier_received(dossier)
send_notification(dossier, dossier.procedure.received_mail_template) send_notification(dossier, dossier.procedure.received_mail_template)

View file

@ -1,3 +1,6 @@
- content_for :procedure_logo do
= render 'layouts/mailers/logo', url: @logo_url
%p %p
Bonjour, Bonjour,
@ -13,4 +16,7 @@
email: email:
= mail_to @dossier.procedure.service.email, @dossier.procedure.service.email = mail_to @dossier.procedure.service.email, @dossier.procedure.service.email
= render partial: "layouts/mailers/signature" = render 'layouts/mailers/signature'
- content_for :footer do
= render 'layouts/mailers/service_footer', service: @service, dossier: @dossier

View file

@ -2,7 +2,7 @@ if !defined?(CONTACT_EMAIL)
CONTACT_EMAIL = "contact@demarches-simplifiees.fr" CONTACT_EMAIL = "contact@demarches-simplifiees.fr"
EQUIPE_EMAIL = "equipe@demarches-simplifiees.fr" EQUIPE_EMAIL = "equipe@demarches-simplifiees.fr"
TECH_EMAIL = "tech@demarches-simplifiees.fr" TECH_EMAIL = "tech@demarches-simplifiees.fr"
NO_REPLY_EMAIL = "Ne pas répondre <ne-pas-repondre@demarches-simplifiees.fr>"
CONTACT_PHONE = "01 76 42 02 87" CONTACT_PHONE = "01 76 42 02 87"
OLD_CONTACT_EMAIL = "contact@tps.apientreprise.fr" OLD_CONTACT_EMAIL = "contact@tps.apientreprise.fr"

View file

@ -4,6 +4,10 @@ RSpec.describe DossierMailer, type: :mailer do
let(:to_email) { 'instructeur@exemple.gouv.fr' } let(:to_email) { 'instructeur@exemple.gouv.fr' }
shared_examples 'a dossier notification' do shared_examples 'a dossier notification' do
it 'is sent from a no-reply address' do
expect(subject.from.first).to eq(Mail::Address.new(NO_REPLY_EMAIL).address)
end
it 'includes the contact informations in the footer' do it 'includes the contact informations in the footer' do
expect(subject.body).to include('ne pas répondre') expect(subject.body).to include('ne pas répondre')
end end
@ -67,4 +71,16 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include("n'a pas pu être supprimé") } it { expect(subject.body).to include("n'a pas pu être supprimé") }
it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include(dossier.procedure.libelle) }
end end
describe '.notify_revert_to_instruction' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
subject { described_class.notify_revert_to_instruction(dossier) }
it { expect(subject.subject).to include('réexaminé') }
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier_url(dossier)) }
it_behaves_like 'a dossier notification'
end
end end

View file

@ -56,5 +56,9 @@ RSpec.describe NotificationMailer, type: :mailer do
expect(mail.body).not_to include('iframe') expect(mail.body).not_to include('iframe')
end end
end end
it 'sends the mail from a no-reply address' do
expect(subject.from.first).to eq(Mail::Address.new(NO_REPLY_EMAIL).address)
end
end end
end end