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

Upgrade email functionality in Oppia to have email attachments #21380

Merged
merged 9 commits into from
Dec 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Removes unnecessary try-except block
  • Loading branch information
Nik-09 committed Dec 28, 2024
commit 8f619920ba4e802dc1fca4f2c90631b538eddb14
37 changes: 17 additions & 20 deletions core/platform/email/mailgun_email_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,22 @@ def send_email_to_recipients(
for attachment in attachments
] if attachments else None

try:
response = requests.post(
server,
auth=('api', mailgun_api_key),
data=data,
files=files,
timeout=TIMEOUT_SECS
)

if files:
for _, (_, file_obj) in files:
file_obj.close()

if response.status_code != 200:
logging.error(
'Failed to send email: %s - %s.'
% (response.status_code, response.text))
return False
except requests.RequestException as e:
logging.error('Failed to send email: %s.' % e)
response = requests.post(
server,
auth=('api', mailgun_api_key),
data=data,
files=files,
timeout=TIMEOUT_SECS
)

if files:
for _, (_, file_obj) in files:
file_obj.close()

if response.status_code != 200:
logging.error(
'Failed to send email: %s - %s.'
% (response.status_code, response.text))
return False

return True