-
Notifications
You must be signed in to change notification settings - Fork 0
Add custom verification email templates with HTML support and placeholder replacement #6
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
Conversation
Co-authored-by: lukbrew25 <79376204+lukbrew25@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull Request Overview
This PR adds customizable email templates for verification codes with HTML support and placeholder replacement, ensuring fallback to defaults and backward compatibility.
- Added
subjectandbodyparameters to the email-sending function, with automatic{verifcode}replacement - Implemented HTML detection to send multipart emails (HTML + plain text)
- Updated Auth class to pass custom templates and extended documentation accordingly
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/easy_mongodb_auth_handler/package_functions/func.py | Added HTML detection, multipart email support, and placeholder replacement in send_verification_email. |
| src/easy_mongodb_auth_handler/auth.py | Updated calls to send_verification_email, and expanded constructor docs for new template parameters. |
| .pylintrc | Disabled the R0914 warning to accommodate increased positional arguments. |
Comments suppressed due to low confidence (1)
src/easy_mongodb_auth_handler/package_functions/func.py:109
- The default subject was previously "Your Verification Code" and is documented as such in the PR description. This change may break existing integrations—consider aligning the default value with prior behavior or clearly documenting the new default.
subject = "Verification Code"
This PR implements custom email templates for verification codes with support for both plain text and HTML content, including automatic placeholder replacement.
Features Added
mail_subjectandmail_bodyparameters to theAuthclass constructor{verifcode}placeholder replacement - Automatic replacement of{verifcode}placeholders in both subject and body with the actual verification codeUsage Examples
Custom Plain Text Templates
HTML Email Templates
Default Behavior (No Changes Required)
Technical Implementation
send_verification_email()function to accept optionalsubjectandbodyparameters<html>,<body>,<p>,<br>,<div>,<span>)send_verification_email()in the Auth class to pass custom templatesFiles Changed
src/easy_mongodb_auth_handler/package_functions/func.py- Enhanced email sending functionsrc/easy_mongodb_auth_handler/auth.py- Updated function calls and documentationTesting
All functionality has been thoroughly tested including:
{verifcode}is replaced, not variations)Fixes #5.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.