Skip to content

BI-2101 - Configure Transactional Email for Production DeltaBreed#351

Merged
mlm483 merged 6 commits intodevelopfrom
feature/BI-2101
May 3, 2024
Merged

BI-2101 - Configure Transactional Email for Production DeltaBreed#351
mlm483 merged 6 commits intodevelopfrom
feature/BI-2101

Conversation

@mlm483
Copy link
Contributor

@mlm483 mlm483 commented Apr 22, 2024

Description

Story: https://breedinginsight.atlassian.net/browse/BI-2101

This PR enables bi-api to send transactional email using SMTP provided the EMAIL_RELAY_HOST, EMAIL_RELAY_PORT, EMAIL_RELAY_LOGIN and EMAIL_RELAY_PASSWORD are provided.

I configured DKIM and DMARC records required by SES so that we can send emails from noreply@breedinginsight.org.

I added an item to the v0.10 Deploy Checklist to update the production environment variables.

If the EMAIL_RELAY_LOGIN and EMAIL_RELAY_PASSWORD variables are omitted or empty, the code will continue to use SMTP without auth, which is desirable in development and non-production deployments.


Background Information

  1. javax.mail docs: https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html

There are many configurable properties, it required some trial and error to get everything right.

  1. obtaining Amazon SES SMTP credentials: https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html

"Your SMTP user name and password are not the same as your AWS access key ID and secret access key."

Dependencies

bi-web develop branch

Testing

Regression Testing

  • With your local .env unchanged, ensure you can still use mailhog as usual.

Feature Functional Testing

  1. Now, set the following in your .env, the credentials have been shared with the dev team.
    EMAIL_RELAY_HOST=email-smtp.us-east-1.amazonaws.com
    EMAIL_RELAY_PORT=25
    EMAIL_RELAY_LOGIN=*****
    EMAIL_RELAY_PASSWORD=*****
    EMAIL_FROM=noreply@breedinginsight.org
  2. See the acceptance criteria on Jira: https://breedinginsight.atlassian.net/browse/BI-2101

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: <please include a link to TAF run>

enabled direct SMTP connection to SES provided the correct authentication environment variables are present
@mlm483 mlm483 requested review from a team, dmeidlin and nickpalladino and removed request for a team April 24, 2024 21:23
Copy link
Member

@nickpalladino nickpalladino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the .env.template files here and in bi-docker-stack should have the new envs added

props.put("mail.debug", true);
return Session.getInstance(props, null);
Authenticator auth = null;
if (Utilities.isNeitherNullNorEmpty(smtpLogin) && Utilities.isNeitherNullNorEmpty(smtpPassword)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could use StringUtils.isNotBlank from apache commons if you wanted to use an existing implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mlm483
Copy link
Contributor Author

mlm483 commented Apr 30, 2024

Thanks for the suggestion @nickpalladino, I opened a PR on bi-docker-stack here.

@mlm483 mlm483 merged commit d36bcce into develop May 3, 2024
@mlm483 mlm483 deleted the feature/BI-2101 branch May 3, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants