|
2 | 2 |
|
3 | 3 | The application may need to send email notifications to users. This document describes how to configure notifications. The notification setup process will: |
4 | 4 |
|
5 | | -1. Create an AWS Pinpoint application for managing notifications |
6 | | -2. Configure Amazon SES (Simple Email Service) for sending emails |
| 5 | +1. Configure Amazon SES (Simple Email Service) for sending emails |
| 6 | +2. Set up the necessary IAM permissions for SES access |
7 | 7 | 3. Set up the necessary environment variables for the application service |
8 | 8 |
|
9 | 9 | ## Requirements |
@@ -32,28 +32,35 @@ make infra-update-app-service APP_NAME=<APP_NAME> ENVIRONMENT=<ENVIRONMENT> |
32 | 32 |
|
33 | 33 | ## 4. Send a test email |
34 | 34 |
|
35 | | -To send a test notification using the AWS CLI, first get the application id for the Pinpoint application/project for the environment you want to test. |
| 35 | +To send a test notification using the AWS CLI, first get the sender email address for the environment you want to test. |
36 | 36 |
|
37 | 37 | ```bash |
38 | 38 | bin/terraform-init "infra/<APP_NAME>/service" "<ENVIRONMENT>" |
39 | | -APPLICATION_ID="$(terraform -chdir=infra/<APP_NAME>/service output -raw pinpoint_app_id)" |
| 39 | +FROM_EMAIL="$(terraform -chdir=infra/<APP_NAME>/service output -raw ses_from_email)" |
40 | 40 | ``` |
41 | 41 |
|
42 | 42 | Then run the following command, replacing `<RECIPIENT_EMAIL>` with the email address you want to send to: |
43 | 43 |
|
44 | 44 | ```bash |
45 | | -aws pinpoint send-messages --application-id "$APPLICATION_ID" --message-request '{ |
46 | | - "Addresses": { |
47 | | - "<RECIPIENT_EMAIL>": { "ChannelType": "EMAIL" } |
48 | | - }, |
49 | | - "MessageConfiguration": { |
50 | | - "EmailMessage": { |
51 | | - "SimpleEmail": { |
52 | | - "Subject": { "Data": "Test notification", "Charset": "UTF-8" }, |
53 | | - "TextPart": { "Data": "This is a message from the future", "Charset": "UTF-8" }, |
54 | | - "HtmlPart": { "Data": "This is a message from the future", "Charset": "UTF-8" } |
| 45 | +aws sesv2 send-email \ |
| 46 | + --from-email-address "$FROM_EMAIL" \ |
| 47 | + --destination "ToAddresses=<RECIPIENT_EMAIL>" \ |
| 48 | + --content '{ |
| 49 | + "Simple": { |
| 50 | + "Subject": { |
| 51 | + "Data": "Test notification", |
| 52 | + "Charset": "UTF-8" |
| 53 | + }, |
| 54 | + "Body": { |
| 55 | + "Text": { |
| 56 | + "Data": "This is a message from the future", |
| 57 | + "Charset": "UTF-8" |
| 58 | + }, |
| 59 | + "Html": { |
| 60 | + "Data": "<p>This is a message from the future</p>", |
| 61 | + "Charset": "UTF-8" |
| 62 | + } |
55 | 63 | } |
56 | | - } |
57 | | - } |
58 | | -}' |
| 64 | + } |
| 65 | + }' |
59 | 66 | ``` |
0 commit comments