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

Mass user email script using Amazon SES #4570

Merged
merged 15 commits into from Aug 8, 2023
Merged

Mass user email script using Amazon SES #4570

merged 15 commits into from Aug 8, 2023

Conversation

LMNTL
Copy link
Contributor

@LMNTL LMNTL commented Aug 7, 2023

Checklist

  1. If you've added code that should be tested, add tests
  2. If you've changed APIs, update (or create!) the documentation
  3. Ensure the tests pass
  4. Make sure that your code lints and that you've followed our coding style
  5. Write a description of your work suitable for publishing on our forum
  6. Mention any related issues in this repository (as #ISSUE) and in other repositories (as kobotoolbox/other#ISSUE)
  7. Open an issue in the docs if there are UI/UX changes

Description

Added a script to send broadcast emails to users using Amazon SES.

Notes

To test this, you'll need the environment variables AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, and either AWS_S3_REGION_NAME or AWS_SES_REGION_NAME to be set.

Before running the script, make sure the constants at the top of the file are set. You'll need to create a blank HTML file in /scripts/ and set EMAIL_HTML_FILENAME to its file name, then do the same with a blank .txt file and EMAIL_TEXT_FILENAME.

You can run the script in test mode (doesn't send any emails) using:
./manage.py runscript mass_user_emails --script-args test

To force re-sending emails to users that have already been emailed:
./manage.py runscript mass_user_emails --script-args force

@LMNTL LMNTL marked this pull request as ready for review August 7, 2023 15:24
@LMNTL LMNTL changed the title Mass user email script Mass user email script using Amazon SES Aug 7, 2023
and min(quota_sends, remaining_sends)
or quota_sends
)
string_sends = remaining_sends >= 0 and remaining_sends or "unlimited"
Copy link
Member

Choose a reason for hiding this comment

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

I have to admit, this took me an embarrassing amount of time to wrap my head around. I don't know if it's worth changing such well-tested code, but I'd offer for future consideration something like

string_sends = remaining_sends if remaining_sends > 0 else "unlimited"

@jnm jnm merged commit e0cbbd1 into beta Aug 8, 2023
4 checks passed
@jnm jnm deleted the feature/mass-user-emails branch August 8, 2023 17:57
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

Successfully merging this pull request may close these issues.

None yet

2 participants