Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using AWS SES instead of GMail relay service #217

Open
qifeng-bai opened this issue May 23, 2024 · 4 comments
Open

Using AWS SES instead of GMail relay service #217

qifeng-bai opened this issue May 23, 2024 · 4 comments
Assignees
Milestone

Comments

@qifeng-bai
Copy link
Contributor

qifeng-bai commented May 23, 2024

Link to #211

At this moment, Alerts use:

grails:
    mail:
        port: 2525
        server: localhost

to forward local Postfix server. Postfix server is configured to use SMPT4Dev on dev environment or Gmail relay service on test / prod env

@brucehyslop mentioned:

If alerts is on a AWS VM, that VM need permission to send to SES. These privileges are setup when provisioning the VM then everything should just work.

If you deploy to non AWS infrastructure then we need to setup AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY , that what comp=-login does for you on local dev environment.

I',adding config to enable/disable the SES library. You could setup the dev config to disable and send to smtp4dev. The comparison accounts SES config will only send to verified email addresses so shouldn't spam real users. You can add your email to the list and you will get those emails.
I'm not sure if there's support for a sandboxed mailbox to view the blocked emails.

@brucehyslop brucehyslop changed the title Using AWS ESE instead of GMail relay service Using AWS SES instead of GMail relay service May 23, 2024
@qifeng-bai
Copy link
Contributor Author

Questions:
1, How to configure the different senders: For example, for alert-test, the sender should be [email protected]
For alerts prod, it should be [email protected]

@qifeng-bai
Copy link
Contributor Author

Issues:

Run './gradlew bootRun' under the terminal which runs with comp-login.

The first error:

Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path.,

After add implementation 'com.amazonaws:aws-java-sdk-sts:1.12.553' in

The error become:
org.springframework.mail.MailSendException: Failed messages: com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: You must specify a value for roleArn and roleSessionName, com.amazonaws.auth.profile.ProfileCredentialsProvider@7bffdb58: Unable to load credentials into profile [profile comp]: AWS Access Key ID is not specified.: ]

@brucehyslop
Copy link

Questions:
1, How to configure the different senders: For example, for alert-test, the sender should be [email protected] For alerts prod, it should be [email protected]

There should be no change to the way the mails from address is configured using config.postie.emailSender this should have a different address for the test and prod environments.

Note: you will need to make sure that the senders email address is verified in the AWS SES configuration for the environment. ie. the [email protected] will need to be verified in prod AWS SES

@brucehyslop
Copy link

To send via SES simply add the the ala-mail library to the alerts dependency and update the grails-mail plugin to the latest version:

    implementation 'org.grails.plugins:mail:4.0.0'
    implementation 'au.org.ala:ala-mail:1.0.0-SNAPSHOT'

You will also need to enable the sending of emails via SES:

mail.ses.enabled = true

You can revert to the SMTP delivery by setting mail.ses.enabled = false in the /data/alerts/config/alerts-config.properties file

@qifeng-bai qifeng-bai modified the milestones: 4.3.0, 4.2.0 May 29, 2024
qifeng-bai added a commit that referenced this issue Jun 2, 2024
disabled as default
qifeng-bai added a commit that referenced this issue Jun 26, 2024
Also includes:
#228 Fixed the issue of not being able to show the entire list on the debug page.
#217 support AWS SES mail service
#196 biosecurity admin page refactoring
Dockerized Mysql and SMTP
hamzajaved-csiro pushed a commit that referenced this issue Jul 8, 2024
Also includes:
#228 Fixed the issue of not being able to show the entire list on the debug page.
#217 support AWS SES mail service
#196 biosecurity admin page refactoring
Dockerized Mysql and SMTP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants