Skip to content

Fix error when mail not configured#284

Merged
FelixFrizzy merged 1 commit intodevelopmentfrom
fix-mails
Sep 5, 2025
Merged

Fix error when mail not configured#284
FelixFrizzy merged 1 commit intodevelopmentfrom
fix-mails

Conversation

@FelixFrizzy
Copy link
Copy Markdown
Collaborator

@FelixFrizzy FelixFrizzy commented Sep 5, 2025

  • Send mail is only triggered when mail is configered

Summary by CodeRabbit

  • Bug Fixes

    • Signup now sends a verification email only when a mail server is configured; if not configured, the email step is skipped and signup proceeds without attempting delivery.
  • Documentation

    • Updated wording in the README’s mail server setup instructions to clarify step 2.

- Send mail is only triggered when mail is configered
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 5, 2025

Walkthrough

Added EMAIL_CONFIGURED boolean in settings, used in views to conditionally send signup verification emails only when SMTP credentials exist. README wording updated in a setup step. No other logic or public API changes.

Changes

Cohort / File(s) Summary of Changes
Email configuration handling
evoks/evoks/settings.py, evoks/evoks/views.py
Introduced EMAIL_CONFIGURED = bool(EMAIL_HOST_USER and EMAIL_HOST_PASSWORD) and imported it in views to guard sending verification emails with if EMAIL_CONFIGURED:.
Docs wording
README.md
Minor wording change in “Configure Mail Server” step (“Fill out” → “Add”); no content or instruction flow changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-mails

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 5, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.31%. Comparing base (c512f0b) to head (69c60a0).
⚠️ Report is 2 commits behind head on development.

Files with missing lines Patch % Lines
evoks/evoks/views.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #284      +/-   ##
===============================================
- Coverage        92.35%   92.31%   -0.05%     
===============================================
  Files               50       50              
  Lines             1845     1847       +2     
===============================================
+ Hits              1704     1705       +1     
- Misses             141      142       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

93-105: Clarify that verification emails are disabled without SMTP creds; fix boolean literal in snippet

  • Readers should know that if EMAIL_HOST_USER/EMAIL_HOST_PASSWORD aren’t set, no verification emails are sent and admins won’t be notified automatically.
  • The example shows EMAIL_USE_TLS = TRUE which is invalid Python; it must be True.

Apply this diff:

-2. Add
+2. Add
     ```
     EMAIL_HOST_USER=your-email
     EMAIL_HOST_PASSWORD=your-password
     ``` 
     in this file. **Caution**: Be aware that the password is stored as plain text!
+    Note: If EMAIL_HOST_USER and EMAIL_HOST_PASSWORD are not set, EVOKS will not send verification emails. New accounts remain pending until a superuser approves them in the Django admin.
 3. Open `evoks/evoks/settings.py` and configure the SMTP server. E.g. for gmail
     ```
     EMAIL_HOST = 'smtp.gmail.com'
     EMAIL_PORT = 587
-    EMAIL_USE_TLS = TRUE
+    EMAIL_USE_TLS = True
     ```
🧹 Nitpick comments (3)
evoks/evoks/settings.py (1)

95-98: Trim whitespace and provide DEFAULT_FROM_EMAIL

Small robustness and ergonomics tweaks.

 EMAIL_HOST_USER = get_env('EMAIL_HOST_USER', '')
 EMAIL_HOST_PASSWORD = get_env('EMAIL_HOST_PASSWORD', '')
-EMAIL_CONFIGURED = bool(EMAIL_HOST_USER and EMAIL_HOST_PASSWORD)
+EMAIL_CONFIGURED = bool(EMAIL_HOST_USER.strip() and EMAIL_HOST_PASSWORD.strip())
+# Used by email utilities; falls back to instance contact address
+DEFAULT_FROM_EMAIL = EMAIL_HOST_USER or EVOKS_MAIL
evoks/evoks/views.py (2)

1-2: Avoid sending with empty recipient list; log when mail is skipped

If no superuser emails exist, send_mail may be a no-op or error depending on backend. Guard on recipients and log when email is intentionally skipped.

 import os
+import logging
+logger = logging.getLogger(__name__)
@@
-            if EMAIL_CONFIGURED:
-                send_mail(
+            if EMAIL_CONFIGURED and emails:
+                send_mail(
                     'Verify a new Evoks account',
                     'Please visit the evoks admin panel {0} and verify the new user'.format(
                         url),
-                    EMAIL_HOST_USER,
+                    EMAIL_HOST_USER,
                     emails,
                     fail_silently=False,
                 )
+            else:
+                logger.warning(
+                    "Signup verification email not sent (EMAIL_CONFIGURED=%s, recipients=%d).",
+                    EMAIL_CONFIGURED, len(emails)
+                )

Also applies to: 106-115


15-15: Prefer django.conf.settings over importing from the settings module

Using from django.conf import settings is the Django convention and eases testing/overrides.

-from evoks.settings import EMAIL_HOST_USER, EMAIL_CONFIGURED
+from django.conf import settings
@@
-                    EMAIL_HOST_USER,
+                    getattr(settings, "DEFAULT_FROM_EMAIL", settings.EMAIL_HOST_USER),

Also applies to: 111-111

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c512f0b and 69c60a0.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • evoks/evoks/settings.py (1 hunks)
  • evoks/evoks/views.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-all
🔇 Additional comments (2)
evoks/evoks/settings.py (1)

95-98: Good guard flag for mail configuration

Computing EMAIL_CONFIGURED from presence of user/password is a simple, effective gate for sending mail.

evoks/evoks/views.py (1)

106-114: All send_mail calls are properly gated
Only occurrence of send_mail in evoks/evoks/views.py is wrapped by if EMAIL_CONFIGURED.

@FelixFrizzy FelixFrizzy merged commit 49545ab into development Sep 5, 2025
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant