-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add AWS SES support for nodemailer (#613)
- Loading branch information
Showing
11 changed files
with
1,155 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,14 @@ DATABASE_SCHEMA=public | |
DATABASE_SSL_SELF=false | ||
PUBLIC_FRONTEND_URL="http://localhost:5173" # Used for emails linking to the frontend | ||
|
||
# SMTP Settings | ||
SMTP_HOST="smtp.example.com" | ||
SMTP_PORT=587 | ||
SMTP_USERNAME="" | ||
SMTP_PASSWORD="" | ||
MAIL_FROM="[email protected]" | ||
MAIL_REPLY_TO="[email protected]" | ||
# AWS SES Settings | ||
AWS_ACCESS_KEY_ID="EXAMPLE_KEY" | ||
AWS_SECRET_ACCESS_KEY="EXAMPLE_SECRET" | ||
AWS_REGION="eu-north-1" | ||
# `MAIL_FROM` and `MAIL_REPLY_TO` variables will not take effect for emails sent by `user-permissions` Strapi plugin | ||
# (f.e. reset password emails) as they are configured separately via Strapi UI in `Settings > Email Templates`. | ||
MAIL_FROM="OpenVAA Voting Advice Application <[email protected]>" | ||
MAIL_REPLY_TO="OpenVAA Admin <[email protected]>" | ||
|
||
# Maildev settings (used only in dev) | ||
MAILDEV_PORT=1080 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,12 @@ DATABASE_SSL_SELF=false | |
PUBLIC_FRONTEND_URL="http://localhost:5173" # Used for emails linking to the frontend | ||
GENERATE_MOCK_DATA_ON_INITIALISE=true # Set to true to enable mock data on an empty database | ||
GENERATE_MOCK_DATA_ON_RESTART=false # Used only in development builds | ||
|
||
AWS_ACCESS_KEY_ID="EXAMPLE_KEY" | ||
AWS_SECRET_ACCESS_KEY="EXAMPLE_SECRET" | ||
AWS_REGION="eu-north-1" | ||
# `MAIL_FROM` and `MAIL_REPLY_TO` variables will not take effect for emails sent by `user-permissions` Strapi plugin | ||
# (f.e. reset password emails) as they are configured separately via Strapi UI in `Settings > Email Templates`. | ||
MAIL_FROM="OpenVAA Voting Advice Application <[email protected]>" | ||
MAIL_REPLY_TO="OpenVAA Admin <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,59 @@ | ||
export default ({env}) => ({ | ||
'users-permissions': { | ||
config: { | ||
jwt: { | ||
expiresIn: '4h' | ||
}, | ||
register: { | ||
allowedFields: ['candidate'] | ||
const aws = require('@aws-sdk/client-ses'); | ||
|
||
export default ({env}) => { | ||
/** | ||
* Strapi initilises nodemailer transporter only once using main plugin config. | ||
* It allows to override only transporter specific (SMPT or SES) settings using [env]/plugins.ts, not the transporter type itself. | ||
* So we have to make sure that for development we initilise the transporter as SMTP to be able to use maildev. | ||
*/ | ||
const emailProviderOptions = | ||
env('NODE_ENV') === 'development' | ||
? undefined | ||
: { | ||
SES: { | ||
ses: new aws.SES({ | ||
apiVersion: '2010-12-01', | ||
region: env('AWS_REGION'), | ||
credentials: { | ||
accessKeyId: env('AWS_ACCESS_KEY_ID'), | ||
secretAccessKey: env('AWS_SECRET_ACCESS_KEY') | ||
} | ||
}), | ||
aws | ||
}, | ||
// max 14 messages per second to comply with AWS SES | ||
sendingRate: 14 | ||
}; | ||
return { | ||
'users-permissions': { | ||
config: { | ||
jwt: { | ||
expiresIn: '4h' | ||
}, | ||
register: { | ||
allowedFields: ['candidate'] | ||
} | ||
} | ||
} | ||
}, | ||
email: { | ||
config: { | ||
provider: 'nodemailer', | ||
providerOptions: { | ||
host: env('SMTP_HOST', 'smtp.example.com'), | ||
port: env('SMTP_PORT', 587), | ||
auth: { | ||
user: env('SMTP_USERNAME'), | ||
pass: env('SMTP_PASSWORD') | ||
}, | ||
email: { | ||
config: { | ||
provider: 'nodemailer', | ||
providerOptions: { | ||
...emailProviderOptions | ||
}, | ||
settings: { | ||
defaultFrom: env('MAIL_FROM'), | ||
defaultReplyTo: env('MAIL_REPLY_TO') | ||
} | ||
}, | ||
settings: { | ||
defaultFrom: env('MAIL_FROM', '[email protected]'), | ||
defaultReplyTo: env('MAIL_REPLY_TO', '[email protected]') | ||
}, | ||
ratelimit: env.NODE_ENV === 'development' && { | ||
max: 10000, | ||
interval: 60000 | ||
} | ||
}, | ||
'import-export-entries': { | ||
enabled: true, | ||
resolve: './strapi-plugin-import-export-entries' | ||
}, | ||
'candidate-admin': { | ||
enabled: true, | ||
resolve: './src/plugins/candidate-admin' | ||
} | ||
}, | ||
'import-export-entries': { | ||
enabled: true, | ||
resolve: './strapi-plugin-import-export-entries' | ||
}, | ||
'candidate-admin': { | ||
enabled: true, | ||
resolve: './src/plugins/candidate-admin' | ||
} | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.