mailers: add a NO_REPLY address to transactional emails

This commit is contained in:
Chaïb Martinez 2019-09-10 11:29:06 +00:00 committed by Pierre de La Morinerie
parent aa1cf6788b
commit dd6c6bfe7a
6 changed files with 17 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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"

View file

@ -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

View file

@ -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