-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Testing email functionality
Ashwath Kannan edited this page Apr 17, 2024
·
1 revision
While it's not feasible to directly receive emails during local testing, you can effectively verify email functionality using these steps:
-
Configuration
-
Enable Emails: Within the
feconf.py
file, confirm that the following flags are set toTrue
:CAN_SEND_EMAILS
- Any other flags pertinent to your configuration for email transmission.
-
Enable Emails: Within the
-
Code Adjustment
-
Modify
send_mail
:- Locate the
send_mail
function incore/domain/email_services.py
. - Add print statements to view the email body, email id, etc, as per the testing requirements.
- Locate the
-
Modify
-
Trigger and Validate
- Actions: Execute actions within local server anticipated to trigger email dispatch (e.g., user registration, feedback submission).
- Cron Jobs: If emails are scheduled, manually initiate the associated cron job endpoint.
- Log Scrutiny: Examine your logs to locate the recorded email details.
Example: Testing the Signup Email
-
Preparation: Ensure
CAN_SEND_EMAILS = True
infeconf.py
. -
Logging Inclusion: Incorporate the following snippet within
core/domain/email_services.py
undersend_mail
:print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('Recipient Email: ', recipient_email)
-
Triggering: Establish a new user account (e.g., username
testuser
, emailtest@example.com
). -
Log Examination:
- Identify the
$$$$$$$
line to easily pinpoint the recipient email.
- Identify the
- Customization: Tailor the logged information to match the specific email under test.
-
Log Search Tools: Utilize your terminal's search capabilities (Ctrl/Cmd+F or similar) or tools like
grep
to streamline log analysis.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- FAQs
- Installing Oppia
- Getting started with the codebase
- Making your first PR
- Learning resources for developers
- Codebase Overview
- Coding Guidelines
- Coding style guide
- Guidelines for creating new files
- How to add a new page
- How to write frontend type definitions
- How to write design docs
- Revert and Regression Policy
- Server errors and solutions
-
Debugging
- If your presubmit checks fail
- If CI checks fail on your PR
- Finding the commit that introduced a bug
- Interpreting GitHub Actions Results
- Debugging Docs
- Debugging datastore locally
- Debugging end-to-end tests
- Debugging backend tests
- Debugging frontend tests
- Debug frontend code
- Debugging custom ESLint check tests
- Debugging custom Pylint check tests
- Debugging Stories
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Lint Checks
- Oppia's code owners and checks to be carried out by developers
- Privacy aware programming
- Backend Type Annotations
- Bytes and string handling in Python 3
- Guidelines for Developers with Write Access to oppia/oppia
- Testing
- Release Process
Developer Reference
- Oppiabot
- Frontend
- Backend
- Translations
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Mobile device testing
- Performance testing
- Build process
- Team structure
- Triaging Process
- Playbooks
- Wiki
- Past Events