-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Upgrade email functionality in Oppia to have email attachments #21380
Conversation
Hi @vojtechjelinek, @DubeySandeep, @kevintab95, PTAL at this PR, it modifies files in jobs or platform folders. |
Hi @Nik-09 please assign the required reviewer(s) for this PR. Thanks! |
@@ -95,16 +100,17 @@ def send_email_to_recipients( | |||
# To send bulk emails we pass list of recipients in 'to' paarameter of | |||
# post data. Maximum limit of recipients per request is 1000. | |||
# For more detail check following link: | |||
# https://documentation.mailgun.com/user_manual.html#batch-sending | |||
# https://documentation.mailgun.com/docs/mailgun/user-manual/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated documentation link.
recipient_email_lists = [ | ||
recipient_emails[i:i + 1000] | ||
for i in range(0, len(recipient_emails), 1000)] | ||
for email_list in recipient_email_lists: | ||
data = { | ||
'from': sender_email, | ||
'subject': subject.encode('utf-8'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to encode manually because the request
library will handle the encoding intrinsically.
# also the docs recommend this approach: | ||
# https://docs.python.org/3.7/library/urllib.request.html#urllib-examples | ||
encoded_url = urllib.parse.urlencode(data).encode('ascii') | ||
req = urllib.request.Request(server, encoded_url, header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the implementation from urllib
to the requests
library as it simplifies attaching files in multipart/form-data and provides built-in support for this format.
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lkbhitesh07 @kevintab95 @U8NWXD PTAL once you get time. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Nik-09! One question, how do we test this?
Hi @Nik-09, it looks like some changes were requested on this pull request by @kevintab95. PTAL. Thanks! |
Hi @kevintab95 I have substituted my Mailgun credentials in a unit test and demonstrated the actual mail-sending functionality with the attachment in the video added in the PR description, PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Nik-09 for explaining how you tested this! LGTM
Hi @Nik-09, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed review @Nik-09, LGTM!
Hi @Nik-09, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to merge this PR once the CI checks pass and you're happy with it. Thanks! |
Overview
Currently, our emailing functionality does not allow for sending emails with attachments. This PR will extend the current functionality to include such a provision.
Essential Checklist
Please follow the instructions for making a code change.
Testing doc (for PRs with Beam jobs that modify production server data)
Proof that changes are correct
I have substituted my Mailgun credentials in a unit test and demonstrated the actual mail-sending functionality with the attachment in the video below.
mail.mp4
Proof of changes on desktop with slow/throttled network
Proof of changes on mobile phone
Proof of changes in Arabic language
PR Pointers