Updated send_to_providers.py to use the notification email_reply_to address if there is one present otherwise it uses the service email_reply_to so now users can choose a per notification email_reply_to address.

This commit is contained in:
Richard Chapman
2017-10-06 16:58:32 +01:00
parent 26d84a873e
commit b311506f37
3 changed files with 91 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ from notifications_utils.recipients import (
from notifications_utils.template import HTMLEmailTemplate, PlainTextEmailTemplate, SMSMessageTemplate
from app import clients, statsd_client, create_uuid
from app.dao.notifications_dao import dao_update_notification
from app.dao.notifications_dao import dao_update_notification, dao_get_notification_email_reply_for_notification
from app.dao.provider_details_dao import (
get_provider_details_by_notification_type,
dao_toggle_sms_provider
@@ -110,13 +110,18 @@ def send_email_to_provider(notification):
from_address = '"{}" <{}@{}>'.format(service.name, service.email_from,
current_app.config['NOTIFY_EMAIL_DOMAIN'])
email_reply_to = dao_get_notification_email_reply_for_notification(notification.id)
if not email_reply_to:
email_reply_to = service.get_default_reply_to_email_address()
reference = provider.send_email(
from_address,
notification.to,
plain_text_email.subject,
body=str(plain_text_email),
html_body=str(html_email),
reply_to_address=service.get_default_reply_to_email_address(),
reply_to_address=email_reply_to,
)
notification.reference = reference
update_notification(notification, provider)