-
-
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
- How to get help
- Getting started with the project
- How the codebase is organized
- Making your first PR
- Debugging
- Testing
- Codebase policies and processes
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Testing jobs and other features on production
- Guidelines for Developers with Write Access to oppia/oppia
- Release schedule and other information
- Revert and Regression Policy
- Privacy aware programming
- Code review:
- Project organization:
- QA Testing:
- Design docs:
- Team-Specific Guides
- LaCE/CD:
- Developer Workflow:
Developer Reference
- Oppiabot
- Git cheat sheet
- Frontend
- Backend
- Backend Type Annotations
- Writing state migrations
- Calculating statistics
- Storage models
- Coding for speed in GAE
- Adding a new page
- Adding static assets
- Wipeout Implementation
- Notes on NDB Datastore transactions
- How to handle merging of change lists for exploration properties
- Instructions for editing roles or actions
- Protocol buffers
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Performance testing
- Build process
- Best practices for leading Oppia teams
- Past Events