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:
commit
a15bbd5b4e
7 changed files with 43 additions and 6 deletions
|
@ -7,4 +7,9 @@ class DeviseUserMailer < Devise::Mailer
|
|||
def template_paths
|
||||
['devise_mailer']
|
||||
end
|
||||
|
||||
def confirmation_instructions(record, token, opts = {})
|
||||
opts[:from] = NO_REPLY_EMAIL
|
||||
super
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class DossierMailer < ApplicationMailer
|
|||
|
||||
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' }
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ class DossierMailer < ApplicationMailer
|
|||
|
||||
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' }
|
||||
end
|
||||
end
|
||||
|
@ -60,8 +60,13 @@ class DossierMailer < ApplicationMailer
|
|||
|
||||
def notify_revert_to_instruction(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
|
||||
|
|
|
@ -12,6 +12,7 @@ class NotificationMailer < ApplicationMailer
|
|||
helper MailerHelper
|
||||
|
||||
layout 'mailers/notifications_layout'
|
||||
default from: NO_REPLY_EMAIL
|
||||
|
||||
def send_dossier_received(dossier)
|
||||
send_notification(dossier, dossier.procedure.received_mail_template)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
- content_for :procedure_logo do
|
||||
= render 'layouts/mailers/logo', url: @logo_url
|
||||
|
||||
%p
|
||||
Bonjour,
|
||||
|
||||
|
@ -13,4 +16,7 @@
|
|||
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
|
||||
|
|
|
@ -2,7 +2,7 @@ if !defined?(CONTACT_EMAIL)
|
|||
CONTACT_EMAIL = "contact@demarches-simplifiees.fr"
|
||||
EQUIPE_EMAIL = "equipe@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"
|
||||
|
||||
OLD_CONTACT_EMAIL = "contact@tps.apientreprise.fr"
|
||||
|
|
|
@ -4,6 +4,10 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
let(:to_email) { 'instructeur@exemple.gouv.fr' }
|
||||
|
||||
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
|
||||
expect(subject.body).to include('ne pas répondre')
|
||||
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(dossier.procedure.libelle) }
|
||||
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
|
||||
|
|
|
@ -56,5 +56,9 @@ RSpec.describe NotificationMailer, type: :mailer do
|
|||
expect(mail.body).not_to include('iframe')
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue