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

Lack of Error Handling in Project's Email SMTP Configuration #30

Closed
WajahatKanju opened this issue Mar 2, 2024 · 4 comments
Closed

Comments

@WajahatKanju
Copy link
Contributor

The current implementation of the email sending functionality in the Django project does not effectively handle errors related to SMTP configuration. Specifically, when an incorrect email SMTP server is entered, the system freezes without providing any error message. This behavior persists regardless of whether the SMTP password is correct or incorrect.

Steps to reproduce the behavior:

  1. Setup the Django project.
  2. Install project dependencies using pip install -r requirements.txt.
  3. Create a superuser using python manage.py createsuperuser.
  4. Trigger an action that sends an email, such as a staff user creating a new entry.
  5. Observe the system behavior and lack of error handling when SMTP configuration errors occur during email transmission.

Expected behavior
I expected the system to handle SMTP configuration errors during email transmission appropriately. Specifically, when encountering an incorrect SMTP configuration, I expected the system to provide informative error messages or notifications, allowing for easier diagnosis and troubleshooting of the issue. Additionally, I anticipated that the system would not freeze but gracefully handle such errors, ensuring the continued functionality of the application.

Error Handling Implementation

Introduce error handling mechanisms within the email sending functionality to appropriately capture and manage SMTP configuration errors.

Exception Handling

Implement exception handling routines to catch potential errors that may arise during the process of sending emails, such as smtplib.SMTPException or smtplib.SMTPAuthenticationError.

Logging
Incorporate logging features to record any encountered errors or exceptions during email transmission. This logging functionality will facilitate troubleshooting and debugging efforts.

User Feedback
Ensure that users receive informative feedback when SMTP configuration errors occur during email transmission. This feedback can be conveyed through user interface notifications or system-generated messages.

Testing
Conduct comprehensive testing of the email sending functionality across various scenarios, including instances where the SMTP configuration is incorrect. This testing will validate the robustness and reliability of the email transmission process.

@adilmohak
Copy link
Owner

Hey @WajahatKanju,

The email sending functionality is now handled by celery tasks, so we can do things like

  • Use Celery's Retry Mechanism: Configure Celery to automatically retry the email sending task in case of transient errors like network issues or temporary SMTP server unavailability.
  • Error Logging: Log any exceptions or errors that occur during the email sending process.
  • Handle Specific SMTP Errors: Identify specific SMTP errors that may occur during email sending, such as connection timeouts, authentication failures, or SMTP server errors.

@WajahatKanju
Copy link
Contributor Author

Sounds good, @adilmohak ! I'll take a thorough look into it to ensure everything is working as intended. Once confirmed, we can mark the issue as closed.

@adilmohak
Copy link
Owner

Great :)

@WajahatKanju
Copy link
Contributor Author

Good Job.

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

No branches or pull requests

2 participants