Send emails with a friendly from name

It’s nicer to have emails with a sender name, as well as the raw email
address.

Amazon SES can acheive this by using the format
```
"Sender name" <sender.name@domain.com>
```
— http://docs.aws.amazon.com/ses/latest/DeveloperGuide/email-format.html
We also have to remove all non-ASCII characters from the sender name,
because SMTP only supports 7-bit ASCII:

> A field name MUST be composed of printable US-ASCII characters (i.e.,
> characters that have values between 33 and 126, inclusive), except
> colon.

— http://www.ietf.org/rfc/rfc5322.txt

We use the service name as the sender name when:
- sending emails from the API
- sending emails from a CSV file

We use GOV.UK Notify as the sender name when:
- sending invitation emails
- sending password reset emails
This commit is contained in:
Chris Hill-Scott
2016-04-25 16:37:55 +01:00
parent 4e4a5abbad
commit ac0fa5b211
4 changed files with 49 additions and 23 deletions

View File

@@ -1012,7 +1012,7 @@ def test_should_allow_valid_email_notification(notify_api, sample_email_template
app.celery.tasks.send_email.apply_async.assert_called_once_with(
(str(sample_email_template.service_id),
notification_id,
"sample.service@test.notify.com",
"\"Sample service\" <sample.service@test.notify.com>",
"something_encrypted",
"2016-01-01T11:09:00.061258"),
queue="email"